123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- /*import {
- extend,
- inherit
- } from "../../src/util";
- describe("util", function () {
- it('inherit', () => {
- function A() {}
- A.prototype = {
- render: function () {
- console.log('111')
- },
- setState: function(){}
- }
- function B() {
- }
- inherit(B, A)
- var b = new B
- expect(b).toInstanceOf(B)
- expect(b).toInstanceOf(A)
- expect(b.render).toBe(A.prototype.render)
- expect(b.setState).toA('function')
- })
- it("oneObject", function () {
- expect(oneObject("aa,bb,cc")).toEqual({
- aa: 1,
- bb: 1,
- cc: 1
- });
- expect(oneObject("")).toEqual({});
- expect(oneObject([1, 2, 3], false)).toEqual({
- 1: false,
- 2: false,
- 3: false
- });
- });
- it("extend", function () {
- expect(extend({}, {
- a: 1,
- b: 2
- })).toEqual({
- a: 1,
- b: 2
- });
- expect(extend({
- a: 1
- }, null)).toEqual({
- a: 1
- });
- });
- it("isFn", function () {
- expect(isFn("sss")).toBe(false);
- expect(isFn(function a() {})).toBe(true);
- });
- it("isEventName", () => {
- expect(isEventName("onaaa")).toBe(false);
- expect(isEventName("onAaa")).toBe(true);
- expect(isEventName("xxx")).toBe(false);
- });
- it("toLowerCase", () => {
- expect(toLowerCase("onaaa")).toBe("onaaa");
- expect(toLowerCase("onA")).toBe("ona");
- expect(toLowerCase("onA")).toBe("ona");
- });
- it("inherit", () => {
- function A() {}
- function B() {}
- inherit(A, B);
- var a = new A;
- expect(a instanceof A).toBe(true);
- expect(a instanceof B).toBe(true);
- });
- it("camelize", function () {
- expect(typeof camelize).toBe("function");
- expect(camelize("aaa-bbb-ccc")).toBe("aaaBbbCcc");
- expect(camelize("aaa_bbb_ccc")).toBe("aaaBbbCcc");
- expect(camelize("-aaa-bbb-ccc")).toBe("aaaBbbCcc");
- expect(camelize("_aaa_bbb_ccc")).toBe("aaaBbbCcc");
- expect(camelize("")).toBe("");
- });
- it("firstLetterLower", function(){
- expect(typeof firstLetterLower).toBe("function");
- expect(firstLetterLower("WebkitBorderStart")).toBe("webkitBorderStart");
- expect(firstLetterLower("")).toBe("");
- });
- it("toArray", () => {
- var dom = {
- childNodes: [{}, {}, {}]
- };
- expect(toArray(dom.childNodes).length).toBe(3);
- });
- it("getChildContext", () => {
- var instance = {
- getChildContext: function () {
- return {
- a: 1
- };
- }
- };
- var b = getChildContext(instance, {
- b: 4
- });
- expect(b).toEqual({
- a: 1,
- b: 4
- });
- });
-
- it("typeNumber", () => {
- var A = function() {};
- var a = new A;
-
- expect(typeNumber(void 2)).toBe(0);
- expect(typeNumber(null)).toBe(1);
- expect(typeNumber(false)).toBe(2);
- expect(typeNumber(true)).toBe(2);
- expect(typeNumber(1)).toBe(3);
- expect(typeNumber("333")).toBe(4);
- expect(typeNumber(A)).toBe(5);
- expect(typeNumber([])).toBe(7);
- expect(typeNumber(a)).toBe(8);
- });
-
- });*/
|