Skip to content

Commit

Permalink
Snapshot update (#134)
Browse files Browse the repository at this point in the history
* Failing specs to test that a new cli rule has been added.

* Happy path for adding a CLI requirement

Created a path to build/add requirements. Much refactor to be done once
all requirement types are included.

* Working implementation for all rules.

Still needs major refactor. Need to add prompt for choosing an existing
requirement or creating a new one with a desired name.

* Working implementation

* Update

* Update snapshot testings for snapshot.ts

* Make TSlint great again.

* Bump Gluegun

* Moving appendSolidaritySettings to an external function.

Tests… coming soon.

* Tests for appendSolidaritySettings

* Empty commit cause Github is confused.

* Retest

* Fix - AppendSettings

This commit test drives and fixes the issue where new settings would
override existing ones.

* Fixes creating a new requirement set

* Support incomplete entry

Allows a user to enter the rule if they did not specify in the original
command.

* Adds support for shell rules

* Found small bug hidden by bad tests.

* Fix broken merge.

* Refactor + Spec fixes

* Make tslint great again

* Handle updates to an already existing rule!!!!!

Could use a refactor! Would love some input.

* Working spec suite.

* Update ruleHandlers

* Remove lines

* Rerun spec suite w/ empty commit.

* Update message to use the rule handler key to build the question for solving the problems.

* Updates snapshots

* Adds failing test

* Fix type that was causing a bug w/ shell

* Update copy for asking the specific for the rule type

* Handles rejection of the undefined second param.

* Handle empty requirement input

* Retest
  • Loading branch information
Matt Thompson authored and GantMan committed Dec 24, 2017
1 parent d55a791 commit e7e59ec
Show file tree
Hide file tree
Showing 10 changed files with 1,186 additions and 26 deletions.
85 changes: 85 additions & 0 deletions __tests__/command_helpers/appendSolidaritySettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import appendSolidaritySettings from '../../src/extensions/functions/appendSolidaritySettings'
import { keys } from 'ramda'
import solidarityExtension from '../../src/extensions/solidarity-extension'
import { solidarity } from '../../src/types';

const context = require('mockContext')

describe('appendSolidaritySettings', () => {

beforeAll(() => {
solidarityExtension(context)

const solidaritySettings = {
$schema: './solidaritySchema.json',
requirements: {
oneTest: [
{ rule: 'cli' },
{ rule: 'env', variable: 'ANDROID_HOME' }
],
twoTest: [{ rule: 'env' }]
}
}

context.solidarity = {
...context.solidarity,
getSolidaritySettings: jest.fn(() => solidaritySettings),
}
})

it('appends the given requirement to the existing settings', () => {
const newRequirement = {
three: [{ rule: 'cli' }]
}

context.parameters = {
first: 'cli'
}

const newSettings = appendSolidaritySettings(context, newRequirement)

expect(keys(newSettings.requirements).length).toEqual(3)
expect(keys(newSettings.requirements.three).length).toEqual(1)

})

it('will append the given requirement to and existing requirement', () => {
context.parameters = {
first: 'cli',
second: 'ruby'
}

const newRequirement = {
twoTest: [{ rule: 'cli', binary: 'ruby' }]
}

let newSettings = appendSolidaritySettings(context, newRequirement)

expect(keys(newSettings.requirements).length).toEqual(2)
expect(newSettings.requirements.twoTest.length).toEqual(2)

expect(Array.isArray(newSettings.requirements.twoTest[0])).toBe(false)
expect(Array.isArray(newSettings.requirements.twoTest[1])).toBe(false)
})

describe('given a requirement with a prexisting rule', () => {
it('should just merge the rule w/ the existing rule', () => {
context.parameters = {
first: 'env'
}

const newRequirement = {
oneTest: [{
rule: 'env',
variable: 'ANDROID_HOME',
error: 'The ANDROID_HOME environment variable must be set to your local SDK. Refer to getting started docs for help.'
}]
}

let newSettings = appendSolidaritySettings(context, newRequirement)

expect(keys(newSettings.requirements).length).toEqual(2)
expect(newSettings.requirements.oneTest.length).toEqual(2)
})
})
})
Loading

0 comments on commit e7e59ec

Please sign in to comment.