Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0237h committed Dec 4, 2024
1 parent e88e972 commit ef1a325
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions packages/cli/tests/cli/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,43 @@ const EXAMPLE_SUBGRAPH_PATH = path.join(__dirname, 'add', 'subgraph');

const TEMP_SUBGRAPH_PATH = path.join(__dirname, 'add', 'tmp-subgraph');

describe('Add command', () => {
beforeAll(async () => {
toolbox.filesystem.remove(TEMP_SUBGRAPH_PATH); // If the tests fail before AfterAll is called
toolbox.filesystem.copy(EXAMPLE_SUBGRAPH_PATH, TEMP_SUBGRAPH_PATH);

await runGraphCli(
[
'add',
'0x2E645469f354BB4F5c8a05B3b30A929361cf77eC',
'--contract-name',
'Gravatar',
'--abi',
`${EXAMPLE_SUBGRAPH_PATH}/abis/Gravity.json`,
],
TEMP_SUBGRAPH_PATH,
);
});

afterAll(async () => {
toolbox.filesystem.remove(TEMP_SUBGRAPH_PATH);
});

it('should add a new datasource to a subgraph', () => {
const manifest = fs.readFileSync(`${TEMP_SUBGRAPH_PATH}/subgraph.yaml`);
const expected = fs.readFileSync(`${__dirname}/add/expected/subgraph.yaml`);

expect(manifest.equals(expected)).toBe(true);
});

it('should not overwrite the ABI file', () => {
const abi = fs.readFileSync(`${TEMP_SUBGRAPH_PATH}/abis/Gravatar.json`);
const expected = fs.readFileSync(`${__dirname}/add/expected/Gravatar.json`);

expect(expected.equals(abi)).toBe(true);
});
}, { timeout: 20_000 });
describe(
'Add command',
() => {
beforeAll(async () => {
toolbox.filesystem.remove(TEMP_SUBGRAPH_PATH); // If the tests fail before AfterAll is called
toolbox.filesystem.copy(EXAMPLE_SUBGRAPH_PATH, TEMP_SUBGRAPH_PATH);

await runGraphCli(
[
'add',
'0x2E645469f354BB4F5c8a05B3b30A929361cf77eC',
'--contract-name',
'Gravatar',
'--abi',
`${EXAMPLE_SUBGRAPH_PATH}/abis/Gravity.json`,
],
TEMP_SUBGRAPH_PATH,
);
});

afterAll(async () => {
toolbox.filesystem.remove(TEMP_SUBGRAPH_PATH);
});

it('should add a new datasource to a subgraph', () => {
const manifest = fs.readFileSync(`${TEMP_SUBGRAPH_PATH}/subgraph.yaml`);
const expected = fs.readFileSync(`${__dirname}/add/expected/subgraph.yaml`);

expect(manifest.equals(expected)).toBe(true);
});

it('should not overwrite the ABI file', () => {
const abi = fs.readFileSync(`${TEMP_SUBGRAPH_PATH}/abis/Gravatar.json`);
const expected = fs.readFileSync(`${__dirname}/add/expected/Gravatar.json`);

expect(expected.equals(abi)).toBe(true);
});
},
{ timeout: 20_000 },
);

0 comments on commit ef1a325

Please sign in to comment.