Skip to content

Commit

Permalink
Merge branch 'new-components' of https://github.com/searchkit/searchkit
Browse files Browse the repository at this point in the history
… into searchkit/new-components
  • Loading branch information
GregoryPotdevin committed Mar 3, 2016
2 parents 0c8bf4f + 8a875d5 commit cc49c3f
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 202 deletions.
30 changes: 15 additions & 15 deletions package.json
Expand Up @@ -53,33 +53,33 @@
"license": "Apache-2.0",
"dependencies": {
"axios": "^0.9.1",
"bem-cn": "^1.2.1",
"es6-promise": "^3.0.2",
"bem-cn": "^1.2.2",
"es6-promise": "^3.1.2",
"history": "^1.17.0",
"lodash": "^4.0.0",
"lodash": "^4.6.1",
"qs": "ssetem/qs",
"rc-slider": "^3.3.1",
"react": "^0.14.6",
"react-addons-update": "^0.14.3"
"rc-slider": "^3.3.2",
"react": "^0.14.7",
"react-addons-update": "^0.14.7"
},
"devDependencies": {
"chalk": "^1.1.1",
"css-loader": "^0.23.1",
"ejs": "^2.4.1",
"enzyme": "^1.3.0",
"enzyme": "^2.0.0",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"html-webpack-plugin": "^2.9.0",
"imports-loader": "^0.6.5",
"istanbul": "^0.4.2",
"istanbul-instrumenter-loader": "^0.1.3",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-ajax": "^3.2.0",
"jasmine-core": "^2.3.4",
"js-beautify": "^1.5.10",
"json-loader": "^0.5.4",
"karma": "^0.13.14",
"karma-coverage": "^0.5.3",
"karma": "^0.13.21",
"karma-coverage": "^0.5.4",
"karma-coveralls": "^1.1.2",
"karma-jasmine": "^0.3.6",
"karma-jasmine-diff-reporter": "^0.3.4",
Expand All @@ -91,7 +91,7 @@
"node-sass": "^3.4.2",
"node-static": "^0.7.7",
"null-loader": "^0.1.1",
"phantomjs-polyfill": "0.0.1",
"phantomjs-polyfill": "0.0.2",
"phantomjs-prebuilt": "^2.1.4",
"react-addons-test-utils": "^0.14.6",
"react-dom": "^0.14.6",
Expand All @@ -101,10 +101,10 @@
"style-loader": "^0.13.0",
"ts-loader": "^0.8.1",
"ts-node": "^0.5.5",
"typescript": "^1.7.0",
"webpack": "^1.12.9",
"webpack-config": "^3.0.0",
"webpack-hot-middleware": "^2.9.0",
"typescript": "^1.8.7",
"webpack": "^1.12.14",
"webpack-config": "^4.0.0",
"webpack-hot-middleware": "^2.9.1",
"xenon": "^0.1.4"
}
}
30 changes: 16 additions & 14 deletions release/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/theme.css

Large diffs are not rendered by default.

File renamed without changes.
@@ -1,7 +1,7 @@
import * as React from "react";
import {mount} from "enzyme";
import {Panel} from "./Panel"
import {fastClick, hasClass, jsxToHTML, printPrettyHtml} from "../../../__test__/TestHelpers"
import {fastClick, hasClass, jsxToHTML, printPrettyHtml} from "../../__test__/TestHelpers"

describe("Panel", ()=> {
beforeEach(()=> {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/layout/index.ts
@@ -1 +1 @@
export * from "./panel/Panel"
export * from "./Panel"
30 changes: 7 additions & 23 deletions src/components/ui/list/ItemListComponents.unit.tsx
Expand Up @@ -10,36 +10,20 @@ import {
CheckboxItemComponent,
} from "./ItemComponents"

import {MockList} from "./MockList";

import {fastClick, hasClass, jsxToHTML, printPrettyHtml} from "../../__test__/TestHelpers"

describe("ItemList Components", ()=> {

beforeEach(()=> {
this.items = [
{key:"a", label:"A", doc_count:10},
{key:"b", label:"B", doc_count:11},
{key:"c", title:"C", doc_count:12},
{key:"d", doc_count:13},
]

this.selectedItems = ["a", "c"]
this.toggleItem = jasmine.createSpy("toggleItem")
this.setItems = jasmine.createSpy("setItems")

this.translate = (key)=> {
return key + " translated"
}

})

it("ItemList should render and behave correctly", ()=> {
let props = {
items:this.items, selectedItems: this.selectedItems,
toggleItem: this.toggleItem, setItems: this.setItems,
translate:this.translate
}
this.wrapper = mount(
<ItemList {...props}/>
<MockList listComponent={ItemList}/>
)

expect(this.wrapper.html()).toEqual(jsxToHTML(
Expand All @@ -58,7 +42,7 @@ describe("ItemList Components", ()=> {
</div>
<div className="sk-item-list-option sk-item-list__item" data-qa="option">
<div data-qa="label" className="sk-item-list-option__text">d translated</div>
<div data-qa="count" className="sk-item-list-option__count">13</div>
<div data-qa="count" className="sk-item-list-option__count">15</div>
</div>
</div>
))
Expand All @@ -76,9 +60,9 @@ describe("ItemList Components", ()=> {
this.wrapper.setProps({mod:"my-item-list"})
expect(this.wrapper.find(".my-item-list").length).toBe(1)

expect(this.toggleItem).not.toHaveBeenCalled()
expect(this.wrapper.node.state.toggleItem).not.toHaveBeenCalled()
fastClick(this.wrapper.find(".my-item-list-option").at(2))
expect(this.toggleItem).toHaveBeenCalledWith("c")
expect(this.wrapper.node.state.toggleItem).toHaveBeenCalledWith("c")
})

it("check default props are set correctly", ()=> {
Expand All @@ -94,7 +78,7 @@ describe("ItemList Components", ()=> {
mod: "sk-item-list-updated", className: "my-custom-class"
}
this.wrapper = mount(
<ItemList {...props}/>
<MockList listComponent={ItemList} mod="sk-item-list-updated" className="my-custom-class"/>
)

expect(this.wrapper.find(".sk-item-list-updated").hasClass("my-custom-class")).toBe(true)
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/list/Select.unit.tsx
Expand Up @@ -38,8 +38,8 @@ describe("Select", ()=> {

expect(this.wrapper.html()).toEqual(jsxToHTML(
<div className="sk-select">
<select>
<option selected value="a">A translated (10)</option>
<select defaultValue="a">
<option value="a">A translated (10)</option>
<option value="b">B translated (11)</option>
<option value="c">C translated (12)</option>
<option value="d">d translated (15)</option>
Expand Down
67 changes: 23 additions & 44 deletions src/components/ui/list/TagCloud.unit.tsx
Expand Up @@ -3,42 +3,21 @@ import {mount} from "enzyme";
const bemBlock = require('bem-cn')

import { TagCloud } from "./TagCloud"
import { MockList } from "./MockList"

import {fastClick, hasClass, jsxToHTML, printPrettyHtml} from "../../__test__/TestHelpers"

describe("TagCloud", ()=> {

beforeEach(()=> {
this.items = [
{key:"a", label:"A", doc_count:10},
{key:"b", label:"B", doc_count:11},
{key:"c", title:"C", doc_count:12},
{key:"d", doc_count:15},
]

this.selectedItems = ["a", "c"]
this.toggleItem = jasmine.createSpy("toggleItem")
this.setItems = jasmine.createSpy("setItems")

this.translate = (key)=> {
return key + " translated"
}
})

it("should render and behave correctly", ()=> {
let props = {
items:this.items, selectedItems: this.selectedItems,
toggleItem: this.toggleItem, setItems: this.setItems,
translate:this.translate
}
this.wrapper = mount(
<TagCloud {...props}/>
<MockList listComponent={TagCloud}/>
)

expect(this.wrapper.html()).toEqual(jsxToHTML(
<div className="sk-tag-cloud">
<span className="sk-tag-cloud__item is-active" data-qa="option" style={{ fontSize: 10 }}>A translated</span>
<span className="sk-tag-cloud__item" data-qa="option" style={{ fontSize: 11 }}>B translated</span>
<span className="sk-tag-cloud__item is-disabled" data-qa="option" style={{ fontSize: 11 }}>B translated</span>
<span className="sk-tag-cloud__item is-active" data-qa="option" style={{ fontSize: 12 }}>C translated</span>
<span className="sk-tag-cloud__item" data-qa="option" style={{ fontSize: 15 }}>d translated</span>
</div>
Expand All @@ -47,24 +26,21 @@ describe("TagCloud", ()=> {
this.wrapper.setProps({disabled:true})
expect(this.wrapper.find(".sk-tag-cloud").hasClass("is-disabled")).toBe(true)

expect(this.toggleItem).not.toHaveBeenCalled()
expect(this.wrapper.node.state.toggleItem).not.toHaveBeenCalled()
fastClick(this.wrapper.find(".sk-tag-cloud__item").at(2))
expect(this.toggleItem).toHaveBeenCalledWith("c")
expect(this.wrapper.node.state.toggleItem).toHaveBeenCalledWith("c")
})

it("should sort items", () => {
let props = {
items: [
{ key: "d", doc_count: 15 },
{ key: "a", label: "a", doc_count: 10 },
{ key: "c", title: "C", doc_count: 12 },
{ key: "b", label: "B", doc_count: 11 },
], selectedItems: this.selectedItems,
toggleItem: this.toggleItem, setItems: this.setItems,
translate: this.translate,
}
let items = [
{ key: "d", doc_count: 15 },
{ key: "a", label: "a", doc_count: 10 },
{ key: "c", title: "C", doc_count: 12 },
{ key: "b", label: "B", doc_count: 11 },
]

this.wrapper = mount(
<TagCloud {...props}/>
<MockList listComponent={TagCloud} items={items}/>
)

expect(this.wrapper.html()).toEqual(jsxToHTML(
Expand All @@ -78,17 +54,20 @@ describe("TagCloud", ()=> {
})

it("mod + classname can be updated", () => {
let props = {
items: this.items, selectedItems: this.selectedItems,
toggleItem: this.toggleItem, setItems: this.setItems,
translate: this.translate,
mod: "sk-other-class", className: "my-custom-class"
}
this.wrapper = mount(
<TagCloud {...props}/>
<MockList listComponent={TagCloud} mod="sk-other-class" className="my-custom-class"/>
)

expect(this.wrapper.find(".sk-other-class").hasClass("my-custom-class")).toBe(true)
})

it("show count", () => {
this.wrapper = mount(
<MockList listComponent={TagCloud} showCount={true}/>
)

expect(this.wrapper.find(".sk-tag-cloud__item").at(0).text())
.toBe("A translated (10)")
})

})
42 changes: 42 additions & 0 deletions test/e2e/server/apps/movie-app/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tsconfig.json
Expand Up @@ -55,8 +55,8 @@
"./src/components/search/search-box/test/SearchboxSpec.tsx",
"./src/components/search/sorting-selector/src/SortingSelector.tsx",
"./src/components/search/sorting-selector/test/SortSelectorSpec.tsx",
"./src/components/ui/layout/panel/Panel.tsx",
"./src/components/ui/layout/panel/Panel.unit.tsx",
"./src/components/ui/layout/Panel.tsx",
"./src/components/ui/layout/Panel.unit.tsx",
"./src/components/ui/list/ItemComponents.tsx",
"./src/components/ui/list/ItemComponents.unit.tsx",
"./src/components/ui/list/ItemListComponents.tsx",
Expand Down
2 changes: 1 addition & 1 deletion typings.json
Expand Up @@ -8,7 +8,7 @@
"history": "github:joemcelroy/DefinitelyTyped/react-router/history.d.ts#8cd79728efa7652d934b2703feeb68bb4802aebb",
"jasmine": "github:joemcelroy/DefinitelyTyped/jasmine/jasmine.d.ts#0d64ea1b82ad1d804892ceec14d98a9be85f64fb",
"jasmine-ajax": "github:joemcelroy/DefinitelyTyped/jasmine-ajax/jasmine-ajax.d.ts#8cd79728efa7652d934b2703feeb68bb4802aebb",
"react": "github:joemcelroy/DefinitelyTyped/react/react.d.ts#d1f6bde13f2209be42e86c3686761e8bfcbb50a5",
"react": "github:DefinitelyTyped/DefinitelyTyped/react/react.d.ts#945ebfe049964e429c2530971b9081f3c0f611df",
"react-addons-create-fragment": "github:joemcelroy/DefinitelyTyped/react/react-addons-create-fragment.d.ts#8cd79728efa7652d934b2703feeb68bb4802aebb",
"react-addons-css-transition-group": "github:joemcelroy/DefinitelyTyped/react/react-addons-css-transition-group.d.ts#8cd79728efa7652d934b2703feeb68bb4802aebb",
"react-addons-linked-state-mixin": "github:joemcelroy/DefinitelyTyped/react/react-addons-linked-state-mixin.d.ts#8cd79728efa7652d934b2703feeb68bb4802aebb",
Expand Down

0 comments on commit cc49c3f

Please sign in to comment.