-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Walk): Add Up Folder navigation
- Loading branch information
Showing
6 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* global describe, expect, test */ | ||
import React from 'react'; | ||
import { render } from 'react-testing-library'; | ||
|
||
import ListFile from '../ListFile'; | ||
|
||
describe('<ListFile />', () => { | ||
test('should render a folder', () => { | ||
const path = 'testPath'; | ||
const { container } = render(<ListFile item={{ mediumType: 'folder', path }} />); | ||
expect(container.querySelector('a').href).toEqual(`http://localhost/?path=${path}`); | ||
}); | ||
|
||
test('should avoid an image', () => { | ||
const { container } = render(<ListFile item={{ mediumType: 'image', ext: 'JPEG' }} />); | ||
expect(container.querySelector('li')).toEqual(null); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* global beforeEach, describe, expect, test */ | ||
import util from '../util'; | ||
|
||
const { | ||
addUpFolderPath, | ||
isImage, | ||
} = util; | ||
|
||
describe('Walk - util', () => { | ||
describe('isImage', () => { | ||
test('detect JPG', () => { | ||
expect(isImage({ mediumType: 'image', ext: 'JPEG' })).toEqual(true); | ||
expect(isImage({ mediumType: 'image', ext: 'jpeg' })).toEqual(true); | ||
expect(isImage({ mediumType: 'image', ext: 'JPG' })).toEqual(true); | ||
expect(isImage({ mediumType: 'image', ext: 'jpg' })).toEqual(true); | ||
}); | ||
|
||
test('ignore RAW', () => { | ||
expect(isImage({ mediumType: 'image', ext: 'RAW' })).toEqual(false); | ||
expect(isImage({ mediumType: 'image', ext: 'ARW' })).toEqual(false); | ||
}); | ||
}); | ||
|
||
describe('addUpFolderPath', () => { | ||
const file = { | ||
filename: '..', | ||
mediumType: 'folder', | ||
}; | ||
let dummyFile; | ||
|
||
beforeEach(() => { | ||
dummyFile = { id: 'testid.js', ext: 'js' }; | ||
}); | ||
|
||
test('hide when at root folder', () => { | ||
expect(addUpFolderPath([dummyFile], null)).toEqual([dummyFile]); | ||
expect(addUpFolderPath([dummyFile])).toEqual([dummyFile]); | ||
expect(addUpFolderPath([dummyFile], '')).toEqual([dummyFile]); | ||
}); | ||
|
||
test('one level deep', () => { | ||
const expectedFile = { ...file, path: '' }; | ||
expect(addUpFolderPath([dummyFile], 'galleries')).toEqual([expectedFile, dummyFile]); | ||
}); | ||
|
||
test('two levels deep', () => { | ||
const expectedFile = { ...file, path: 'galleries' }; | ||
expect(addUpFolderPath([dummyFile], 'galleries/gallery-demo')).toEqual([expectedFile, dummyFile]); | ||
}); | ||
|
||
test('three levels deep', () => { | ||
const expectedFile = { ...file, path: 'galleries/gallery-demo' }; | ||
expect(addUpFolderPath([dummyFile], 'galleries/gallery-demo/thumbs')).toEqual([expectedFile, dummyFile]); | ||
}); | ||
}); | ||
}); |
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