Skip to content

Commit

Permalink
Merge pull request #4 from pulsar-edit/add-dugite-tests
Browse files Browse the repository at this point in the history
Add dugite tests
  • Loading branch information
confused-Techie authored Oct 23, 2023
2 parents 63109e4 + 2ecb7f5 commit 86292b1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
steps:
- name: Checkout the latest code
uses: actions/checkout@v3
with:
fetch-depth: 0
# Make sure we get all commits, since testing uses the local git info
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/getDiff.artifact.fixture.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DO NOT CHANGE THIS FILE
7 changes: 7 additions & 0 deletions test/fixtures/getDiff.fixture.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
diff --git a/test/fixtures/getDiff.artifact.fixture.txt b/test/fixtures/getDiff.artifact.fixture.txt
index 6b08561..88e9a2c 100644
--- a/test/fixtures/getDiff.artifact.fixture.txt
+++ b/test/fixtures/getDiff.artifact.fixture.txt
@@ -1 +1 @@
-Never Change this File
+DO NOT CHANGE THIS FILE
File renamed without changes.
13 changes: 11 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { deepEqual } = require("assert");
const { translateLinesGivenDiff, diffPositionToFilePosition } = require("../src/index.js");
const { translateLinesGivenDiff, diffPositionToFilePosition, getDiff } = require("../src/index.js");
const { readFileSync } = require("fs");

const fixture = require('js-yaml').safeLoad(readFileSync(require.resolve('./index.fixture.yaml')))
const fixture = require('js-yaml').safeLoad(readFileSync(require.resolve('./fixtures/index.fixture.yaml')))

describe('translateLinesGivenDiff', () => {
it('translates rows after applying a diff', () => {
Expand Down Expand Up @@ -64,3 +64,12 @@ describe('diffPositionToFilePosition', () => {
})
})
})

describe('getDiff', () => {
it('returns accurate getDiff', async () => {
// Use this repo's git info, checking the artifact fixture file
const diff = await getDiff('./', 'test/fixtures/getDiff.artifact.fixture.txt', '286ccffe38885e731ed4894989dbc6d2c0f85f72');
const diffFixture = readFileSync(require.resolve('./fixtures/getDiff.fixture.txt'), "utf8");
deepEqual(diff, diffFixture);
});
});

0 comments on commit 86292b1

Please sign in to comment.