Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Oct 26, 2023
1 parent ed59821 commit c0b0461
Showing 1 changed file with 47 additions and 33 deletions.
80 changes: 47 additions & 33 deletions fastn-core/src/tutor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,43 +163,57 @@ mod test {

#[test]
fn test() {
assert_eq!(
super::TutorStateFS {
done: vec![],
current: "".to_string(),
}
.to_state("tutor-tests/one")
.unwrap(),
super::TutorState {
workshops: vec![
super::Workshop {
title: "Build Websites Using `fastn`".to_string(),
url: "/a-website/".to_string(),
let mut ts = super::TutorState {
workshops: vec![
super::Workshop {
title: "Build Websites Using `fastn`".to_string(),
url: "/a-website/".to_string(),
done: false,
current: false,
tutorials: vec![super::Tutorial {
id: "a-website/01-hello-world".to_string(),
url: "/a-website/01-hello-world/".to_string(),
title: "Install and start using `fastn`".to_string(),
done: false,
current: false,
tutorials: vec![super::Tutorial {
id: "a-website/01-hello-world".to_string(),
url: "/a-website/01-hello-world/".to_string(),
title: "Install and start using `fastn`".to_string(),
done: false,
current: false,
}],
},
super::Workshop {
title: "Build User Interfaces Using `fastn`".to_string(),
url: "/b-ui/".to_string(),
}],
},
super::Workshop {
title: "Build User Interfaces Using `fastn`".to_string(),
url: "/b-ui/".to_string(),
done: false,
current: false,
tutorials: vec![super::Tutorial {
id: "b-ui/01-hello-world".to_string(),
url: "/b-ui/01-hello-world/".to_string(),
title: "Install and start using `fastn`".to_string(),
done: false,
current: false,
tutorials: vec![super::Tutorial {
id: "b-ui/01-hello-world".to_string(),
url: "/b-ui/01-hello-world/".to_string(),
title: "Install and start using `fastn`".to_string(),
done: false,
current: false,
}],
}
]
}],
},
],
};

assert_eq!(
super::TutorStateFS::default()
.to_state("tutor-tests/one")
.unwrap(),
ts,
);

ts.workshops[0].tutorials[0].done = true;
ts.workshops[0].done = true;
ts.workshops[1].current = true;
ts.workshops[1].tutorials[0].current = true;

assert_eq!(
super::TutorStateFS {
done: vec!["a-website/01-hello-world".to_string()],
current: "b-ui/01-hello-world".to_string(),
}
)
.to_state("tutor-tests/one")
.unwrap(),
ts,
);
}
}

0 comments on commit c0b0461

Please sign in to comment.