Created
April 1, 2020 02:55
-
-
Save Nkzn/900d4c970dbff16b4cbb06c2ba9bc77b to your computer and use it in GitHub Desktop.
ES Modulesで「プライベートメソッドをテストする」をやりたいとき
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function publicFunction() { | |
} | |
function complexPrivateFunctionA() { | |
} | |
function complexPrivateFunctionB() { | |
} | |
function complexPrivateFunctionC() { | |
} | |
export const __dangerousExportForTesting = { | |
complexPrivateFunctionA, | |
complexPrivateFunctionB, | |
complexPrivateFunctionC, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
publicFunction, | |
__dangerousExportForTesting, | |
} from './functions'; | |
describe('publicFunction', () => { | |
test('hoge', () => { | |
publicFunction(); | |
}); | |
}); | |
describe('complexPrivateFunctionA', () => { | |
const { complexPrivateFunctionA } = __dangerousExportForTesting; | |
test('hoge', () => { | |
complexPrivateFunctionA(); | |
}); | |
}); | |
describe('complexPrivateFunctionB', () => { | |
const { complexPrivateFunctionB } = __dangerousExportForTesting; | |
test('hoge', () => { | |
complexPrivateFunctionB(); | |
}); | |
}); | |
describe('complexPrivateFunctionC', () => { | |
const { complexPrivateFunctionC } = __dangerousExportForTesting; | |
test('hoge', () => { | |
complexPrivateFunctionC(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment