Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chinedufn committed Jan 18, 2019
1 parent 85025a9 commit ea518d7
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -6,10 +6,10 @@ INSTALL_DEPS: &INSTALL_DEPS
- rustup default nightly
- rustup target add wasm32-unknown-unknown
# Install WASM bindgen CLI
- curl -OL https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.28/wasm-bindgen-0.2.28-x86_64-unknown-linux-musl.tar.gz
- tar xf wasm-bindgen-0.2.28-x86_64-unknown-linux-musl.tar.gz
- chmod +x wasm-bindgen-0.2.28-x86_64-unknown-linux-musl/wasm-bindgen
- mv wasm-bindgen-0.2.28-x86_64-unknown-linux-musl/wasm-bindgen* ~/.cargo/bin/ # wasm-bindgen and wasm-bindgen-test-runner binaries
- curl -OL https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.31/wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz
- tar xf wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz
- chmod +x wasm-bindgen-0.2.31-x86_64-unknown-linux-musl/wasm-bindgen
- mv wasm-bindgen-0.2.31-x86_64-unknown-linux-musl/wasm-bindgen* ~/.cargo/bin/ # wasm-bindgen and wasm-bindgen-test-runner binaries
# Install Node.js
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
- source ~/.nvm/nvm.sh
Expand Down
16 changes: 11 additions & 5 deletions Dockerfile
Expand Up @@ -9,13 +9,18 @@ RUN rustup target add wasm32-unknown-unknown \

# Node.js & npm
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y nodejs

# Install WASM bindgen CLI
RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.25/wasm-bindgen-0.2.25-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-bindgen" &&\
RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.31/wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-bindgen" &&\
chmod +x wasm-bindgen* &&\
mv wasm-bindgen* /usr/local/bin/

# Install WASM pack
RUN curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.6.0/wasm-pack-v0.6.0-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-pack" &&\
chmod +x wasm-pack &&\
mv wasm-pack /usr/local/bin/

WORKDIR /usr/src

COPY package.json package-lock.json ./
Expand All @@ -25,10 +30,11 @@ RUN npm install

COPY . ./

WORKDIR /usr/src/examples/isomorphic

# TODO: Unused.. the server code just expects this directory to be there at the moment.....
RUN mkdir client/build
RUN mkdir /usr/src/examples/isomorphic/client/build
RUN touch /usr/src/examples/isomorphic/client/build/unused.txt

WORKDIR /usr/src/examples/isomorphic

RUN ./build.release.sh

Expand Down
4 changes: 2 additions & 2 deletions crates/virtual-dom-rs/Cargo.toml
Expand Up @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
js-sys = "0.3"
wasm-bindgen = {version = "0.2", features = ["default", "nightly"]}
wasm-bindgen = {version = "0.2.31", features = ["default", "nightly"]}
virtual-node = { path = "../virtual-node", version = "0.0.1" }

[dependencies.web-sys]
Expand All @@ -33,7 +33,7 @@ features = [
]

[dev-dependencies]
wasm-bindgen-test = "0.2"
wasm-bindgen-test = "0.2.31"

[dev-dependencies.web-sys]
version = "0.3"
Expand Down
42 changes: 21 additions & 21 deletions crates/virtual-dom-rs/src/patch.rs
Expand Up @@ -7,37 +7,37 @@ use wasm_bindgen::JsCast;
use web_sys;
use web_sys::{Element, Node};

use wasm_bindgen::JsValue;

/// A `Patch` encodes an operation that modifies a real DOM element.
/// A Patch encodes an operation that modifies a real DOM element.
///
/// To update the real DOM that a user sees you'll want to first diff your
/// old virtual dom and new virtual dom.
///
/// This diff operation will generate `Vec<Patch>` with zero or more patches that, when
/// This diff operation will generate Vec<Patch> with zero or more patches that, when
/// applied to your real DOM, will make your real DOM look like your new virtual dom.
///
/// Each `Patch` has a u32 node index that helps us identify the real DOM node that it applies to.
/// Each Patch has a u32 node index that helps us identify the real DOM node that it applies to.
///
/// Our old virtual dom's nodes are indexed depth first, as shown in this illustration
/// (0 being the root node, 1 being it's first child, 2 being it's first child's first child).
///
/// .─.
/// ( 0 )
/// `┬'
/// ┌────┴──────┐
/// │ │
/// ▼ ▼
/// .─. .─.
/// ( 1 ) ( 4 )
/// `┬' `─'
/// ┌────┴───┐ │
/// │ │ ├─────┬─────┐
/// ▼ ▼ │ │ │
/// .─. .─. ▼ ▼ ▼
/// ( 2 ) ( 3 ) .─. .─. .─.
/// `─' `─' ( 5 ) ( 6 ) ( 7 )
/// `─' `─' `─'
/// ```ignore
/// .─.
/// ( 0 )
/// `┬'
/// ┌────┴──────┐
/// │ │
/// ▼ ▼
/// .─. .─.
/// ( 1 ) ( 4 )
/// `┬' `─'
/// ┌────┴───┐ │
/// │ │ ├─────┬─────┐
/// ▼ ▼ │ │ │
/// .─. .─. ▼ ▼ ▼
/// ( 2 ) ( 3 ) .─. .─. .─.
/// `─' `─' ( 5 ) ( 6 ) ( 7 )
/// `─' `─' `─'
/// ```
///
/// We'll revisit our indexing in the future when we optimize our diff/patch process.
#[derive(Debug, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion crates/virtual-node/Cargo.toml
Expand Up @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
js-sys = "0.3"
wasm-bindgen = {version = "0.2", features = ["default", "nightly"]}
wasm-bindgen = {version = "0.2.31", features = ["default", "nightly"]}

[dependencies.web-sys]
version = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions crates/virtual-node/src/lib.rs
Expand Up @@ -148,7 +148,7 @@ impl VirtualNode {
///
/// These get patched into the DOM using `document.createElement`
///
/// ```
/// ```ignore
/// use virtual_dom_rs::VirtualNode;
///
/// let div = VirtualNode::new("div");
Expand All @@ -171,7 +171,7 @@ impl VirtualNode {
///
/// These get patched into the DOM using `document.createTextNode`
///
/// ```
/// ```ignore
/// use virtual_dom_rs::VirtualNode;
///
/// let div = VirtualNode::text("div");
Expand Down
2 changes: 1 addition & 1 deletion examples/isomorphic/client/Cargo.toml
Expand Up @@ -13,7 +13,7 @@ isomorphic-app = { path = "../app" }
virtual-dom-rs = { path = "../../../crates/virtual-dom-rs" }

[dependencies.wasm-bindgen]
version = "0.2"
version = "0.2.31"
features = ["default", "nightly"]

[dependencies.web-sys]
Expand Down
1 change: 1 addition & 0 deletions examples/isomorphic/client/src/lib.rs
@@ -1,3 +1,4 @@

use wasm_bindgen;
use wasm_bindgen::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion test.sh
Expand Up @@ -4,4 +4,4 @@ cd $(git rev-parse --show-toplevel)

cargo build --all && # Make sure examples compile
cargo test --all &&
cargo test -p virtual-dom-rs --target wasm32-unknown-unknown
wasm-pack test crates/virtual-dom-rs --firefox --headless

0 comments on commit ea518d7

Please sign in to comment.