Skip to content

Commit

Permalink
add tests for findPluginInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
GantMan committed Feb 4, 2018
1 parent d8c37f2 commit 1faf25d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions __tests__/command_helpers/__snapshots__/findPluginInfo.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`findPluginInfo Function can find plugins 1`] = `
Object {
"plugin": Object {
"check": [Function],
"report": [Function],
"snapshot": [Function],
},
"success": true,
}
`;
37 changes: 37 additions & 0 deletions __tests__/command_helpers/findPluginInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const findPluginInfo = require('../../src/extensions/functions/findPluginInfo')
const examplePlugin = require('examplePlugin')
const mockContext = examplePlugin(require('mockContext'))

describe('findPluginInfo Function', () => {
test('can fail to find plugins', () => {
const rule = {
rule: 'custom',
plugin: 'FAKE',
name: 'checkThing'
}
const customPluginRule = findPluginInfo(rule, mockContext)
expect(customPluginRule).toEqual({ message: "Plugin not found 'FAKE'", success: false })
}

test('can fail to find plugins', () => {
const rule = {
rule: 'custom',
plugin: 'Example Plugin',
name: 'FAKE'
}
const customPluginRule = findPluginInfo(rule, mockContext)
expect(customPluginRule.message).toEqual("NOT FOUND: Custom rule from 'Example Plugin' plugin with check function 'FAKE'")
expect(customPluginRule.success).toBeFalsy()
}

test('can find plugins', () => {
const rule = {
rule: 'custom',
plugin: 'Example Plugin',
name: 'checkThing'
}
const customPluginRule = findPluginInfo(rule, mockContext)
expect(customPluginRule.success).toBeTruthy()
expect(customPluginRule).toMatchSnapshot()
}
})

0 comments on commit 1faf25d

Please sign in to comment.