Skip to content

Commit

Permalink
test: Add some spec coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkr committed May 20, 2019
1 parent f31e088 commit 3e1271e
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"lint": "eslint lib test",
"lint-fix": "eslint --fix lib test",
"test": "jest",
"test": "npm run lint && jest",
"preview": "standard-version --dry-run",
"release": "standard-version && git push --follow-tags"
},
Expand Down
88 changes: 88 additions & 0 deletions test/module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,99 @@ describe('FeatureToggle', () => {

expect(actual).toBe(false)
})

it('should return true if the query string matches and is enabled', () => {
const wrapper = getWrapper({
extraQuery: {
'toggle_my-unique-toggle': 'true'
},
extraFeatureToggle: {
queryString: true
}
})

const actual = wrapper.vm.canShow

expect(actual).toBe(true)
})
})

describe('canShowWithQueryString', () => {
it('should return true if the query string matches', () => {
const wrapper = getWrapper({
extraQuery: {
'toggle_my-unique-toggle': 'true'
},
extraFeatureToggle: {
queryString: true
}
})

const actual = wrapper.vm.canShowWithQueryString

expect(actual).toBe(true)
})
})

describe('queryStringKey', () => {
it('should return the correct key', () => {
const wrapper = getWrapper()

const actual = wrapper.vm.queryStringKey

expect(actual).toBe('toggle_my-unique-toggle')
})
})

describe('queryString', () => {
it('should return the true if the query string is enabled', () => {
const wrapper = getWrapper({
extraFeatureToggle: {
queryString: true
}
})
const actual = wrapper.vm.queryString

expect(actual).toBe(true)
})

it('should return the false if the query string is disabled', () => {
const wrapper = getWrapper({
extraFeatureToggle: {
queryString: false
}
})
const actual = wrapper.vm.queryString

expect(actual).toBe(false)
})
})

describe('isQueryStringAllowed', () => {
it('should return true if is allowed', () => {
const wrapper = getWrapper({
extraFeatureToggle: {
queryString: true,
isQueryStringAllowedFn: () => true
}
})

const actual = wrapper.vm.isQueryStringAllowed

expect(actual).toBe(true)
})

it('should return false if not allowed', () => {
const wrapper = getWrapper({
extraFeatureToggle: {
queryString: true,
isQueryStringAllowedFn: () => false
}
})

const actual = wrapper.vm.isQueryStringAllowed

expect(actual).toBe(false)
})
})
})

0 comments on commit 3e1271e

Please sign in to comment.