Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare master for v5 release. #551

Merged
merged 15 commits into from
Jun 1, 2019
Prev Previous commit
Next Next commit
Fix blob-reader units tests after refactoring
  • Loading branch information
Stefan Buck committed Jun 1, 2019
commit f1c21b3cac7ac7d01e5dba528104f2edbdfe4c8d
4 changes: 3 additions & 1 deletion packages/blob-reader/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ function getPath(el) {

// When current page is a gist, get path from blob name
if (!ret && isGist()) {
ret = $('.gist-blob-name', el.parentElement).text();
ret = $('.gist-blob-name', el.parentElement)
.text()
.trim();
if (ret && !ret.startsWith('/')) {
ret = `/${ret}`;
}
Expand Down
4 changes: 0 additions & 4 deletions packages/blob-reader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import Blob from './blob';
import { getBlobWrapper } from './helper';

export default class BlobReader {
constructor() {
this._blobs = [];
}

hasBlobs() {
return !!getBlobWrapper(document).length;
}
Expand Down
22 changes: 11 additions & 11 deletions packages/blob-reader/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html',
);
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

describe('contains blob path', () => {
Expand All @@ -31,7 +31,7 @@ describe('blob-reader', () => {
);
const reader = new BlobReader();

expect(reader.read().getBlobs()[0].path).toBe(
expect(reader.read()[0].path).toBe(
'/OctoLinker/testrepo/blob/9981d1a99ef8fff1f569c2ae24b136d5a0275132/sourcereader/popular-cat-names.js',
);
});
Expand All @@ -42,7 +42,7 @@ describe('blob-reader', () => {
);
const reader = new BlobReader();

expect(reader.read().getBlobs()[0].path).toBe(
expect(reader.read()[0].path).toBe(
'/OctoLinker/testrepo/blob/64dc9c25b3e09d1d9af437e09d968d08ad5ec903/sourcereader/popular-cat-names.js',
);
});
Expand All @@ -53,7 +53,7 @@ describe('blob-reader', () => {
);
const reader = new BlobReader();

expect(reader.read().getBlobs()[1].path).toBe(
expect(reader.read()[1].path).toBe(
'/OctoLinker/testrepo/blob/cc14b0ce8b94b7044f8c5d2d7af656270330bca2/sourcereader/popular-rabbit-names.js',
);
});
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/blob/89f13651df126efdb4f1e3ae40183c9fdccdb4d3.html',
);
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

it('contains four lines', () => {
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_split.html',
);
const reader = new BlobReader();
[blob] = reader.read()._blobs;
[blob] = reader.read();
});

it('sets isDiff indicator to true', () => {
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_unified.html',
);
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

it('sets isDiff indicator to true', () => {
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/commit/b0775a93ea27ee381858ddd9fa2bb953d5b74acb_unified.html',
);
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

it('fetch raw blob and update blob.lines property', async () => {
Expand All @@ -244,11 +244,11 @@ describe('blob-reader', () => {
'/packages/blob-reader/fixtures/github.com/gist/113827963013e98c6196db51cd889c39.html',
);
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

it('contains blob path', () => {
expect(blob.path).toBe('package.json');
expect(blob.path).toBe('/package.json');
});
});

Expand All @@ -258,7 +258,7 @@ describe('blob-reader', () => {
beforeEach(() => {
fixture.load('/packages/blob-reader/fixtures/github.com/issue/code.html');
const reader = new BlobReader();
[blob] = reader.read().getBlobs();
[blob] = reader.read();
});

it('contains blob root element', () => {
Expand Down