|
1 | | -import DummyClass from "../src/dev-to-git" |
2 | | - |
3 | | -/** |
4 | | - * Dummy test |
5 | | - */ |
6 | | -describe("Dummy test", () => { |
7 | | - it("works if true is truthy", () => { |
8 | | - expect(true).toBeTruthy() |
| 1 | +import { DevToGit, DEFAULT_CONFIG_PATH } from '../src/dev-to-git' |
| 2 | + |
| 3 | +describe(`DevToGit`, () => { |
| 4 | + beforeEach(() => { |
| 5 | + process.argv = ['don-t-care', 'don-t-care'] |
| 6 | + process.env.DEV_TO_GIT_TOKEN = 'token' |
9 | 7 | }) |
10 | 8 |
|
11 | | - it("DummyClass is instantiable", () => { |
12 | | - expect(new DummyClass()).toBeInstanceOf(DummyClass) |
| 9 | + describe(`Config`, () => { |
| 10 | + describe(`Get config`, () => { |
| 11 | + it(`should have by default a path "./dev-to-git.json"`, () => { |
| 12 | + const devToGit = new DevToGit() |
| 13 | + expect(devToGit.getConfigPath()).toBe(DEFAULT_CONFIG_PATH) |
| 14 | + }) |
| 15 | + |
| 16 | + it(`should accept a "config" argument to change the path to the config`, () => { |
| 17 | + const CUSTOM_CONFIG_PATH: string = './custom/dev-to-git.json' |
| 18 | + process.argv = [ |
| 19 | + 'don-t-care', |
| 20 | + 'don-t-care', |
| 21 | + '--config', |
| 22 | + CUSTOM_CONFIG_PATH |
| 23 | + ] |
| 24 | + const devToGit = new DevToGit() |
| 25 | + expect(devToGit.getConfigPath()).toBe(CUSTOM_CONFIG_PATH) |
| 26 | + }) |
| 27 | + |
| 28 | + it(`should use the default path if the "config" flag is passed without nothing`, () => { |
| 29 | + process.argv = ['don-t-care', 'don-t-care', '--config'] |
| 30 | + const devToGit = new DevToGit() |
| 31 | + expect(devToGit.getConfigPath()).toBe(DEFAULT_CONFIG_PATH) |
| 32 | + }) |
| 33 | + }) |
| 34 | + |
| 35 | + describe(`Read config from file`, () => { |
| 36 | + it(`test`, () => { |
| 37 | + process.argv = [ |
| 38 | + 'don-t-care', |
| 39 | + 'don-t-care', |
| 40 | + '--config', |
| 41 | + './test/dev-to-git.json' |
| 42 | + ] |
| 43 | + |
| 44 | + const devToGit = new DevToGit() |
| 45 | + |
| 46 | + expect(devToGit.readConfigFile()).toEqual(require('./dev-to-git.json')) |
| 47 | + }) |
| 48 | + }) |
13 | 49 | }) |
| 50 | + |
| 51 | + // describe(`Article`, () => { |
| 52 | + // describe(`Read`, () => { |
| 53 | + // it(`should read an article from the configuration`, () => { |
| 54 | + // const CUSTOM_CONFIG_PATH: string = './test/dev-to-git.json' |
| 55 | + // process.argv = [ |
| 56 | + // 'don-t-care', |
| 57 | + // 'don-t-care', |
| 58 | + // '--config', |
| 59 | + // CUSTOM_CONFIG_PATH |
| 60 | + // ] |
| 61 | + // const devToGit = new DevToGit() |
| 62 | + // expect(devToGit.readArticleOnDisk()).toContain( |
| 63 | + // 'This is my awesome article!' |
| 64 | + // ) |
| 65 | + // expect(devToGit.readArticleOnDisk()).toContain('Hey, some text!') |
| 66 | + // }) |
| 67 | + // }) |
| 68 | + // describe(`Publish`, () => { |
| 69 | + // it(`should publish the article`, () => { |
| 70 | + // const CUSTOM_CONFIG_PATH: string = './test/dev-to-git.json' |
| 71 | + // process.argv = [ |
| 72 | + // 'don-t-care', |
| 73 | + // 'don-t-care', |
| 74 | + // '--config', |
| 75 | + // CUSTOM_CONFIG_PATH |
| 76 | + // ] |
| 77 | + // const devToGit = new DevToGit() |
| 78 | + // devToGit.publishArticle(devToGit.readConfigFile()[0]) |
| 79 | + // }) |
| 80 | + // }) |
| 81 | + // }) |
14 | 82 | }) |
0 commit comments