Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
test: add resetConfig to clear test state
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 3, 2018
1 parent a617ab1 commit 7c21e7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {expect, fancy} from 'fancy-test'
import * as os from 'os'
import * as path from 'path'

import * as Config from '../src'

import {expect, fancy} from './test'

describe('PluginConfig', () => {
fancy
.resetConfig()
.env({}, {clear: true})
.stub(os, 'homedir', () => path.join('/my/home'))
.stub(os, 'platform', () => 'darwin')
Expand All @@ -21,6 +23,7 @@ describe('PluginConfig', () => {
})

fancy
.resetConfig()
.env({}, {clear: true})
.stub(os, 'homedir', () => path.join('/my/home'))
.stub(os, 'platform', () => 'linux')
Expand All @@ -36,6 +39,7 @@ describe('PluginConfig', () => {
})

fancy
.resetConfig()
.env({LOCALAPPDATA: '/my/home/localappdata'}, {clear: true})
.stub(os, 'homedir', () => path.join('/my/home'))
.stub(os, 'platform', () => 'win32')
Expand Down
17 changes: 17 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {expect, fancy as base, FancyTypes, NockScope} from 'fancy-test'

import * as Config from '../src'

export const fancy = base
.register('resetConfig', () => ({
run(ctx: {config: Config.IConfig}) {
Config.Plugin.loadedPlugins = {}
delete ctx.config
}
}))

export {
expect,
FancyTypes,
NockScope,
}

0 comments on commit 7c21e7e

Please sign in to comment.