Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

big change: delete legacy files

  • Loading branch information...
commit 7b3a9b0b3b53fd79b059133327c5cbbe83adcbc1 1 parent 7c91c3e
@tmtk75 authored
Showing with 2 additions and 7,257 deletions.
  1. +1 −1  .gitignore
  2. +0 −72 app.coffee
  3. +0 −34 lib/css/theme/cool.scss
  4. +0 −25 lib/css/theme/monotone.scss
  5. +0 −121 lib/css/theme/pop.scss
  6. +0 −39 lib/js/legacy/0.1.0/class-diagramSpec.coffee
  7. +0 −114 lib/js/legacy/0.1.0/jumly.DSLSpec.coffee
  8. +0 −85 lib/js/legacy/0.1.0/jumly.attrsSpec.coffee
  9. +0 −187 lib/js/legacy/0.1.0/jumly.commonsSpec.coffee
  10. +0 −105 lib/js/legacy/0.1.0/jumly.diagramSpec.coffee
  11. +0 −36 lib/js/legacy/0.1.0/jumly.iconSpec.coffee
  12. +0 −134 lib/js/legacy/0.1.0/jumly.identificationSpec.coffee
  13. +0 −146 lib/js/legacy/0.1.0/jumly.objectSpec.coffee
  14. +0 −78 lib/js/legacy/0.1.0/jumly.propertySpec.coffee
  15. +0 −442 lib/js/legacy/0.1.0/jumlySpec.coffee
  16. +0 −1,030 lib/js/legacy/0.1.0/sequence-diagramSpec.coffee
  17. +0 −268 lib/js/legacy/0.1.0/sequence.DSLSpec.coffee
  18. +0 −62 lib/js/legacy/0.1.0/sequence.fragment.altSpec.coffee
  19. +0 −23 lib/js/legacy/0.1.0/sequence.fragment.loopSpec.coffee
  20. +0 −352 lib/js/legacy/0.1.0/sequence.fragmentSpec.coffee
  21. +0 −590 lib/js/legacy/0.1.0/sequence.interactionSpec.coffee
  22. +0 −173 lib/js/legacy/0.1.0/sequence.lifelineSpec.coffee
  23. +0 −117 lib/js/legacy/0.1.0/sequence.message.createSpec.coffee
  24. +0 −43 lib/js/legacy/0.1.0/sequence.message.returnSpec.coffee
  25. +0 −590 lib/js/legacy/0.1.0/sequence.messageSpec.coffee
  26. +0 −380 lib/js/legacy/0.1.0/sequence.refSpec.coffee
  27. +0 −23 lib/js/legacy/0.1.0/spec.coffee
  28. +0 −75 lib/js/legacy/0.1.0/usecase-diagramSpec.coffee
  29. +0 −302 lib/js/legacy/0.1.0/usecase.DSLSpec.coffee
  30. +0 −200 lib/js/legacy/0.1.1/JUMLYSpec.coffee
  31. +0 −115 lib/js/legacy/0.1.1/builderSpec.coffee
  32. +0 −97 lib/js/legacy/0.1.1/classSpec.coffee
  33. +0 −34 lib/js/legacy/0.1.1/diagramSpec.coffee
  34. +0 −25 lib/js/legacy/0.1.1/elementSpec.coffee
  35. +0 −132 lib/js/legacy/0.1.1/referingSpec.coffee
  36. +0 −186 lib/js/legacy/0.1.1/sequenceSpec.coffee
  37. +0 −8 lib/js/legacy/0.1.1/spec.coffee
  38. +0 −65 lib/js/legacy/0.1.1/usecaseSpec.coffee
  39. +0 −10 lib/js/legacy/0.1.2/JUMLYHTMLElementSpec.coffee
  40. +0 −23 lib/js/legacy/0.1.2/sequenceSpec.coffee
  41. +0 −2  lib/js/legacy/0.1.2/spec.coffee
  42. +0 −8 lib/js/legacy/NOTE.md
  43. +0 −34 lib/js/legacy/helper.coffee
  44. +0 −235 lib/js/legacy/jasmine-story.coffee
  45. +0 −32 lib/js/spec/layout/ElementLayoutSpec.coffee
  46. +0 −36 lib/js/spec/looks/fullSpec.coffee
  47. +0 −5 lib/js/spec/position/BrowserSpec.coffee
  48. +0 −160 lib/js/spec/position/PositionSpec.coffee
  49. +0 −38 lib/js/spec/position/SequenceDiagramSpec.coffee
  50. +0 −63 lib/js/spec/position/jQuerySpec.coffee
  51. +0 −4 lib/js/spec/requires.coffee
  52. +0 −13 lib/js/spec/struct/SequenceDiagramSpec.coffee
  53. +0 −14 lib/js/spec/struct/jQuerySpec.coffee
  54. +0 −19 lib/js/spec/struct/jasmine-node-helper.coffee
  55. +0 −25 lib/js/spec/struct/jumlySpec.coffee
  56. +0 −20 lib/js/spec/struct/metaSpec.coffee
  57. +0 −6 lib/js/spec/struct/notationSpec.coffee
  58. +1 −1  lib/version
View
2  .gitignore
@@ -1,4 +1,4 @@
.project
node_modules
-public/*.css
+views/static/*.css
*.swp
View
72 app.coffee
@@ -15,75 +15,3 @@ app.get "/", (req,res)->
app.listen port = 3000
console.log "Listening at #{port}"
-
-###
-fs = require "fs"
-express = require "express"
-assets = require "connect-assets"
-jade = require "jade"
-stylus = require 'stylus'
-_ = require 'underscore'
-yaml = require 'js-yaml'
-
-jumly = (str, type)->
- str = str.replace /\\n/g, '\n'
- js = str.replace(/\\/g, '\\\\').replace /\n/g, '\\n'
- """<script type="text/jumly+#{type}">\\n#{js}</script>"""
-
-jade.filters["jumly_sequence"] = (str)-> jumly str, "sequence"
-jade.filters["jumly_class"] = (str)-> jumly str, "class"
-jade.filters["jumly_usecase"] = (str)-> jumly str, "usecase"
-jade.filters["code"] = (str)->
- str = str.replace /\\n/g, '\n'
- js = str.replace(/\\/g, '\\\\').replace /\n/g, '\\n'
- """<pre class="brush: html">#{js}</pre>"""
-
-
-app = module.exports = express.createServer()
-app.configure ->
- app.set "views", __dirname + "/views"
- app.set "view engine", "jade"
- app.use stylus.middleware
- src:"#{__dirname}/views/stylesheets"
- dest:"#{__dirname}/public"
- app.use express.bodyParser()
- app.use express.methodOverride()
- app.use app.router
- app.use express.static __dirname + "/public"
- app.use assets src:"lib/jumly"
-app.configure "development", -> app.use express.errorHandler dumpExceptions: true, showStack: true
-app.configure "production", -> app.use express.errorHandler()
-
-
-lang_resources = yaml.load fs.readFileSync("views/tryjumly.i18n").toString()
-
-conf =
- VERSION: fs.readFileSync("lib/jumly/version").toString()
- markdown: (path)-> require("markdown-js").parse fs.readFileSync(path).toString()
- title: "JUMLY"
- layout: true
-
-i18n =
- value: (key, lang="en")->
- a = lang_resources[key.toLowerCase()]
- return key unless a
- a[lang] || key
-
-app.get "/", (req, res)-> res.render 'index', conf
-app.get /^\/([^;.]+)(;([a-z]+))?$/, (req, res)->
- mkparams = (req, opts)-> _.extend {}, conf, {i18n:_:(key)->i18n.value key, req.params[2]}, opts
- name = req.params[0]
- layouts =
- tryjumly :false
- spec :false
- reference:true
- legacy :false
- res.render name, mkparams req, layout:layouts[name]
-
-port = 3000
-if process.env.NODE_ENV is "heroku"
- console.log "run on heroku"
- port = process.env.PORT
-app.listen port, ->
- console.log "Express server listening on port %d in %s mode", app.address().port, app.settings.env
-###
View
34 lib/css/theme/cool.scss
@@ -1,34 +0,0 @@
-@import "../_commons";
-
-$c0: #527bc6;
-$c1: lighten($c0, 10%);
-$c2: lighten($c1, 10%);
-$c3: lighten($c2, 10%);
-$c4: lighten($c3, 10%);
-
-.sequence-diagram.theme-cool {
- .object .name {
- color: white;
- text-shadow: rgba(0,0,0,0.8) 3px 0px 2px;
- font-weight: bold;
- white-space: nowrap;
- padding: {
- left: 0.5em;
- right: 0.5em;
- }
- &:hover {
- color: complement($c0);
- }
- }
- .object .name, .occurrence {
- background-color: $c0;
- @include border_radius(4px);
- white-space: nowrap;
- }
- .message .name {
- &:hover {
- color: invert($c0);
- }
- }
-}
-
View
25 lib/css/theme/monotone.scss
@@ -1,25 +0,0 @@
-/* Monotone-style */
-@import "../_commons";
-
-$darkgray: #444;
-$c1: lighten($darkgray, 65%);
-
-.sequence-diagram.theme-monotone {
- .object .name {
- @include border_radius(6px);
- background-color: $c1;
- text-shadow: 2px 0px white;
- }
- .message {
- .name {
- color: white;
- background-color: $darkgray;
- padding: 0.25em 0.5em 0.5em 0.5em;
- @include border_radius(6px);
- opacity: 0.66;
- @include box_shadow;
- border: 1px solid black;
- }
- }
-}
-
View
121 lib/css/theme/pop.scss
@@ -1,121 +0,0 @@
-@import "../_object";
-@import "../_relationship";
-
-.component-diagram {
- $min_width: 88*2;
- $min_height: $min_width*5/8;
- $r: 16;
-
- .component {
- > .frame {
- padding-top: 0.5em;
- padding-left: 1em;
- @include primary_border;
- min-width: #{$min_width}px;
- min-height: #{$min_height}px;
- @include box_shadow;
- margin-left: #{$r*2 + $primary_border_width}px; // Space to put interfaces
- margin-right: #{$r*2 + $primary_border_width}px; // Space to put interfaces
- background-color: white;
- -webkit-border-radius: 4px;
- > .stereotype {
- text-align: center;
- }
- > .name {
- text-align: center;
- font-weight: bold;
- }
- > .icon {
- $t: $r;
- width: #{$t*8/5}px;
- height: #{$t*8/5}px;
- margin-left: auto;
- margin-right: 1em;
- @include primary_border;
- @include box_shadow2;
- &:before, &:after {
- content: ' ';
- position: absolute;
- width: #{$t}px;
- height: #{$t/2}px;
- @include primary_border;
- margin-top : #{$primary_border_width}px;
- margin-left: -#{$t/2 + $primary_border_width}px;
- background-color: white;
- }
- &:after {
- margin-top: #{$t*8/5 - $t/2 - $primary_border_width*3}px;
- }
- }
- }
- .provided-interface, .required-interface {
- position: absolute;
- -z-index: -1; // ignore in order to show whole of name.
- > .icon {
- width: #{$r*2}px;
- height: #{$r + $primary_border_width*2}px;
- > * {
- position: absolute;
- @include box_shadow;
- }
- &:before, &:after { // 'after' is line.
- content: ' ';
- position: absolute;
- width: #{$r}px;
- }
- &:before {
- height: #{$r}px;
- @include box_shadow;
- }
- &:after {
- border-top: #{$primary_border_width}px $primary_border_style $primary_border_color;
- margin-top: #{$r/2}px;
- margin-left: #{$r+$primary_border_width}px;
- }
- }
- &.to-right .name {
- margin-left: 1em;
- }
- }
- .provided-interface > .icon {
- &:before {
- @include primary_border;
- background-color: white;
- -webkit-border-radius: #{$r}px;
- }
- }
- .required-interface > .icon { // 'U' shape icon
- &:before {
- border-right: #{$primary_border_width}px $primary_border_style $primary_border_color;
- border-top: #{$primary_border_width}px $primary_border_style $primary_border_color;
- border-bottom: #{$primary_border_width}px $primary_border_style $primary_border_color;
- -webkit-border-top-right-radius : #{$r}px;
- -webkit-border-bottom-right-radius: #{$r}px;
- }
- }
- .port {
- display: none;
- > .icon {
- width: #{$r*3/4}px;
- height: #{$r*3/4}px;
- @include primary_border;
- }
- }
- }
- .component {
- $mg: 10%;
- &:nth-child(odd) {
- float: left;
- margin-right: $mg;
- margin-left: $mg;
- margin-top: 8px;
- }
- &:nth-child(even) {
- float: right;
- margin-left: $mg;
- margin-right: $mg;
- margin-top: 24px;
- }
- }
-}
-
View
39 lib/js/legacy/0.1.0/class-diagramSpec.coffee
@@ -1,39 +0,0 @@
-u = $.jumly
-mkdiag = ->
- diag = u ".class-diagram"
- diag.appendTo $ "body"
- diag
-
-description "class-diagram", ->
-
- description "instanciation", ->
-
-
- description "width", ->
-
- it "should be greater than zero", ->
- diag = mkdiag()
-
- diag.append u ".class", "foobar"
- diag.compose()
-
- diag.width().shouldBeGreaterThan 0
- diag.width().shouldBeGreaterThan diag.find(".class .icon").width()
-
-
- description "height", ->
-
- it "should be greater than zero", ->
- diag = mkdiag()
-
- diag.append u ".class", "foobar"
- diag.compose()
-
- diag.height().shouldBeGreaterThan 0
- diag.height().shouldBeGreaterThan diag.find(".class .icon").height()
-
-
- description "method", ->
-
-
- description "DSL", ->
View
114 lib/js/legacy/0.1.0/jumly.DSLSpec.coffee
@@ -1,114 +0,0 @@
-u = $.jumly
-description "JUMLY.DSL", ->
-
- description "@beforeCompose", ->
-
- it "should run a closure before composing", ->
- diag = u ".sequence-diagram"
- diag.found "Need something name", ->
- @beforeCompose (e, d) ->
- d.foobar = 1
- @afterCompose (e, d) ->
- d.bizbuz = 2 if d.foobar is 1
- diag.compose()
- expect(diag.foobar).toBe 1
- expect(diag.bizbuz).toBe 2
-
- description "@afterCompose", ->
-
- it "should run a closure after composing", ->
- diag = u ".sequence-diagram"
- holder = null
- counter = 0
- diag.found "Need something name 1", ->
- @afterCompose (e, d) ->
- holder = d
- counter += 1
-
- diag.compose()
- expect(diag).toBe holder
- expect(counter).toBe 1
-
- diag.compose()
- expect(counter).toBe 2
-
-
- description "@preferences", ->
-
- it "should be set every instance", ->
- diag = u ".sequence-diagram"
- diag.found "Need something name-1", -> @preferences compose_most_left:0, compose_span:48
- prefs = diag.preferences()
- prefs.compose_most_left.shouldBe 0
- prefs.compose_span.shouldBe 48
-
- it "should be not changed from before", ->
- diag = u ".sequence-diagram"
- prefs = diag.preferences(".sequence-diagram")
- expect(prefs.WIDTH ).toBeDefined()
- expect(prefs.HEIGHT).toBeDefined()
-
- it "should return the same instance every call", ->
- a = $.jumly.preferences(".sequence-diagram")
- b = $.jumly.preferences(".sequence-diagram")
- expect(a).toBe b
-
- it "should return different instance every call", ->
- diag = u ".sequence-diagram"
- a = diag.preferences()
- b = diag.preferences()
- expect(a).toNotBe b
-
- it "should be set for all instances of .sequence-diagram", ->
- oldone = u ".sequence-diagram"
- oldprefs = oldone.preferences()
-
- prefs = $.jumly.preferences(".sequence-diagram")
- old = most_left:prefs.compose_most_left, span:prefs.compose_span
- prefs.compose_most_left = 0
- prefs.compose_span = 48
-
- newone = u ".sequence-diagram"
- newprefs = newone.preferences()
-
- oldprefs.compose_most_left.shouldBe old.most_left
- oldprefs.compose_span .shouldBe old.span
- newprefs.compose_most_left.shouldBe 0
- newprefs.compose_span .shouldBe 48
- expect(oldprefs).toNotBe newprefs
-
-
- shared_scenario 'registeration for a DSL', ->
- given "a compiler (which is just a function)", ->
- when_it "register it", ->
- JUMLY.DSL type:'.hello-world', version:'0.0.1', compileScript: -> "Hello World"
- then_it "return a result", ->
- compiler = (JUMLY.DSL '.hello-world')
- a = compiler.compileScript "something"
- expect(compiler.version).toBe '0.0.1'
- expect(a).toBe 'Hello World'
-
- scenario "latest DSL use", ->
- it_behaves_as "registeration for a DSL"
- when_it "register a new DSL", ->
- JUMLY.DSL type:'.hello-world', version:'0.0.2', compileScript: -> "Stay hungry, Stay foolish"
- then_it "return a result", ->
- compiler = (JUMLY.DSL '.hello-world')
- a = compiler.compileScript "something"
- expect(compiler.version).toBe '0.0.2'
- expect(a).toBe 'Stay hungry, Stay foolish'
-
-
- description "irregular arguments", ->
-
- it "can't accept null", -> expect(-> JUMLY.DSL null).toThrow("It MUST NOT be null.")
-
- it "can't accept undefined", -> expect(-> JUMLY.DSL undefined).toThrow()
-
- it "can't accept boolean", -> expect(-> JUMLY.DSL true).toThrow()
-
- it "can't accept Array", -> expect(-> JUMLY.DSL []).toThrow()
-
- it "can't accept number", -> expect(-> JUMLY.DSL 123).toThrow()
-
-
View
85 lib/js/legacy/0.1.0/jumly.attrsSpec.coffee
@@ -1,85 +0,0 @@
-description "attr", ->
- it "has stereotype property to read/write", ->
- diag = $.jumly ".sequence-diagram"
- diag.found "A", ->
- @create "B"
- msg = (diag.find ".message:last").self()
- (msg.hasClass "create").shouldBeTruthy()
- #msg.jprops().stereotypes().length.shouldBe 1
-
- it "has name property to read/write", ->
- diag = $.jumly ".sequence-diagram"
- diag.found "A", ->
- @message "call", "B"
- msg = (diag.find ".message:last").self()
- #msg.jprops().name.shouldBe "call"
-
- scenario "a string at 2nd parameter in creation", ->
- given "a string at 2nd parameter", ->
- @obj_a = $.jumly(".object", "hello world")
- then_it "the value is in nodes has .name", ->
- obj_a.find(".name:eq(0)").html().shouldBe "hello world"
-
- scenario "an object at 2nd parameter in creation", ->
- given "an object having 'name' at 2nd parameter", ->
- @obj_a = $.jumly(".object", name: "hello world2")
- then_it "the value of the name property for the object is in nodes has .name", ->
- obj_a.find(".name:eq(0)").html().shouldBe "hello world2"
-
- scenario "name method", ->
- given "an object", ->
- @obj_a = $.jumly(".object")
- and_ "an interaction", ->
- @iact_aa = obj_a.activate().interact(obj_a)
- when_it "set a value with name to obj_a", ->
- @p = obj_a.name("foobar")
- and_ "set a value with name to iact_aa", ->
- @q = iact_aa.name("fizbuz")
- then_it "a value is in the object's .name", ->
- obj_a.find(".name:eq(0)").html().shouldBe "foobar"
- and_ "a value is in the interaction's .name", ->
- iact_aa.find(".name:eq(0)").html().shouldBe "fizbuz"
- then_it "p is obj_a", ->
- (p == obj_a).shouldBe true
- and_ "q is iact_aa", ->
- (q == iact_aa).shouldBe true
-
- scenario "basic attributes", ->
- given "a fragment", ->
- @diagram = $.jumly(".sequence-diagram")
- .append(@obj_a = $.jumly(".object").offset(left: 50).css(width: 88, height: 31))
- .append(@obj_b = $.jumly(".object").offset(left: 150).css(width: 88, height: 31))
- diagram.appendTo $("body")
- obj_a.activate().interact obj_b
- @frag = $.jumly(".fragment")
- .enclose($("> .interaction:eq(0)", diagram))
- .name("Loop-0")
- .find(".condition").html("[person is empty]")
- then_it "name of the fragment is 'Loop-0'", ->
- frag.find(".name").html().shouldBe "Loop-0"
- and_ "condition of the fragment is the value", ->
- frag.find("> .header .condition").html().shouldBe "[person is empty]"
-
- shared_behavior "all elements", ->
- given "all elements", ->
- @diagram = $.jumly(".sequence-diagram")
- .append(@obj_a = $.jumly(".object").offset(left: 50).css(width: 88, height: 31))
- .append(@obj_b = $.jumly(".object").offset(left: 150).css(width: 88, height: 31))
- diagram.appendTo $("body")
- obj_a.activate().interact(obj_b)
- .interact(obj_b)
- .interact(obj_b)
- @frag = $.jumly(".fragment").enclose($("> .interaction:eq(0)", diagram))
- diagram.compose()
-
- scenario "message stereotype", ->
- it_behaves_as "all elements"
- then_it "it has .asynchronous class", ->
- and_ "it has .synchronous class", ->
- and_ "it has .create class", ->
- and_ "it has .destroy class", ->
-
- xscenario "diagram listener", ->
- it 'can recognize diagram composed to use lazy-invocation after resizing', ->
- "NOT IMPLEMENTED".shouldBe ""
-
View
187 lib/js/legacy/0.1.0/jumly.commonsSpec.coffee
@@ -1,187 +0,0 @@
-that = exports ? this
-describe "commons", ->
- beforeEach =>
- that.obj = $.jumly ".object"
-
- it "should have name", ->
- expect(that.obj.name).toBeDefined()
- it "should be function", ->
- expect(typeof that.obj.name).toBe "function"
- it "should store value", ->
- that.obj.name 'Taro'
- expect(that.obj.name()).toBe 'Taro'
-
- description "mostLeftRight", ->
- scenario "unattached node", ->
- given "a div", ->
- @div = $("<div>").append($("<div>"))
- when_it "get the metrix", ->
- @a = $("div", div).mostLeftRight()
- then_it "0", ->
- expect(0).toBe @a.left
- then_it "should be outerWidth of the inside object", ->
- w = $("div", div).outerWidth()
- expect(w).toBe @a.right
- then_it "should occupy 1px", ->
- expect(1).toBe @a.width()
-
- scenario "node under body", ->
- given "three objects", ->
- div = $("<div>")
- .append($("<div>").width(100).offset left:0)
- .append($("<div>").width(100).offset left:100 + 50)
- .append($("<div>").width(100).offset left:100 + 50 + 100 + 50)
- .find("div").css("position", "absolute").end()
- $("body").append div
- @a = $("div", div).mostLeftRight()
- then_it "left", ->
- expect(a.left).toBe 0
- then_it "right", ->
- a.right.shouldBe 100 + 50 + 100 + 50 + 100 - 1
- then_it "width", ->
- a.width().shouldBe 100 + 50 + 100 + 50 + 100
-
- describe "name, stereotype", ->
- it "should be function", ->
- that.obj = $.jumly(".object")
- expect(typeof that.obj.name).toBe 'function'
- expect(typeof that.obj.stereotype).toBe 'function'
-
- beforeEach ->
- that.obj = $.jumly(".object")
-
- it "shouldn't call other methods", ->
- that.obj.name('Taro')
- .stereotype('racer')
- n = that.obj.name()
- m = that.obj.stereotype()
- expect(typeof n).toBe 'string'
- expect(typeof m).toBe 'string'
- expect(n).toBe 'Taro'
- expect(m).toBe 'racer'
-
- it "shouldn't call other methods", ->
- that.obj.name('Jiro')
- .stereotype('engineer')
- expect(that.obj.name()).toBe 'Jiro'
- expect(that.obj.stereotype()).toBe 'engineer'
-
- it "should call compose", ->
- diag = $.jumly(".sequence-diagram")
- spyOn diag, "compose"
- diag.compose()
- expect(diag.compose).toHaveBeenCalledWith()
-
- description "pickup2", ->
- shared_behavior "pick up 2 nodes", ->
- given "4 divs in a div", ->
- @div = $("<div>").append($("<div>").addClass "a")
- .append($("<div>").addClass "b")
- .append($("<div>").addClass "c")
- .append($("<div>").addClass "d")
- when_it "pick up by 2", ->
- @a1 = []
- f0 = (a) -> @a0 = a
- f1 = (a, b, i) -> @a1.push a:a, b:b, i:i
- $("div", div).pickup2 f0, f1
-
- scenario "pick up 2 nodes", ->
- it_behaves_as "pick up 2 nodes"
- then_it "three nodes are in the @a", ->
- @a0.hasClass("a").shouldBe true
- @a1.length.shouldBe 3
- and_ "for [0]", ->
- e = @a1[0]
- e.a.hasClass("a").shouldBe true
- e.b.hasClass("b").shouldBe true
- e.i.shouldBe 1
- and_ "for [1]", ->
- e = @a1[1]
- e.a.hasClass("b").shouldBe true
- e.b.hasClass("c").shouldBe true
- e.i.shouldBe 2
- and_ "for [2]", ->
- e = @a1[2]
- e.a.hasClass("c").shouldBe true
- e.b.hasClass("d").shouldBe true
- e.i.shouldBe 3
-
- scenario "empty node set", ->
- when_it "select empty", ->
- @a = $("span", div)
- then_it "nothing happens", ->
- f0 = -> throw "a"
- f1 = -> throw "b"
- @a.pickup2 f0, f1
-
- scenario "1 node set", ->
- when_it "select one node", ->
- @a = $(".a", div)
- then_it "nothing happens", ->
- f0 = ->
- f1 = -> throw "b"
- @a.pickup2 f0, f1
-
- scenario "3rd closure", ->
- when_it "select one node", ->
- @callcount = 0
- f = -> @callcount++
- g = (a, b, i) ->
- @a = a:a, b:b, i:i
- $("div", div).pickup2 f, f, g
- then_it "3rd closure is called for the last set", ->
- @a.a.hasClass("c").shouldBe true
- @a.b.hasClass("d").shouldBe true
- @a.i.shouldBe 3
- and_ ->
- @callcount.shouldBe 3 # except for the last node
-
- description "constructor", ->
- scenario "name by string", ->
- given "an object with a string at 2nd args", ->
- @a = $.jumly ".object", "foobar"
- then_it "name() is", ->
- a.name().shouldBe 'foobar'
- then_it "should have a node", ->
- a.find(".name").text().shouldBe 'foobar'
-
- scenario "name by object", ->
- given "an object with param", ->
- @a = $.jumly ".object", name:"foobar"
- then_it "name() is", ->
- a.name().shouldBe 'foobar'
- then_it "should have a node", ->
- a.find(".name").text().shouldBe 'foobar'
-
- it "has some types", ->
- canvas = $("<canvas>")
- .appendTo($ "body")
- .attr(width: 386, height: 80*8)[0]
- ctxt = canvas.getContext('2d')
- y = 0
- g = (s) ->
- y += 80
- $.g2d.arrow ctxt, {x:0, y:y}, {x:380, y:y}, {shape:s, shadowColor:'rgba(0,0,0,0.33)', shadowBlur:4, shadowOffsetX:10, shadowOffset:5}
- g 'both'
- g 'line'
- g 'line2'
- g 'dashed'
- g 'dashed2'
- g 'normal'
-
- it "should return mostleft", ->
- a = $("<div id='foo'>").css(position:"absolute", left:0, top:0, width:100, height:50, border:"1px red solid", "mergin-left":5).offset(left:25)
- b = $("<div id='bar'>").css(position:"absolute", left:0, top:0, width:100, height:50, border:"1px green solid", "padding-right":10).offset(left:50, top:25)
- $("body").append a
- $("body").append b
- mlr = $("#foo, #bar").mostLeftRight()
- mlr.left.shouldBe 25
- mlr.right.shouldBe 161
- mlr.width().shouldBe 137
-
- description "mostLeftRight", ->
- it "should be 0 for left/right", ->
- lr = $("<div>").mostLeftRight()
- expect(lr.left).toBe 0
- expect(lr.right).toBe 0
-
View
105 lib/js/legacy/0.1.0/jumly.diagramSpec.coffee
@@ -1,105 +0,0 @@
-description "diagram", ->
- shared_behavior "a sequence diagram", ->
- given "a sequence diagram", ->
- @diag = $.jumly(".sequence-diagram")
- $("body").append(diag)
-
- scenario "width of an empty sequence diagram", ->
- it_behaves_as "a sequence diagram"
- when_it "composed", ->
- diag.compose()
- then_it "should be 0", ->
- expect(0).toEqual diag.preferredWidth()
-
- shared_behavior "a composed sequence diagram", ->
- it_behaves_as "a sequence diagram"
- given "an object", ->
- diag.append @obj_a = $.jumly(".object")
- when_it "is composed", ->
- diag.compose()
-
- scenario "width of sequence diagram", ->
- it_behaves_as "a composed sequence diagram"
- then_it "should be greater than obj_a's width", ->
- expect(obj_a.width() <= diag.preferredWidth()).toBeTruthy()
-
- description "width of sequence diagram", ->
- shared_behavior "two objects in sequence diagram", ->
- given "two objects in a diagram", ->
- @diag = $.jumly(".sequence-diagram")
- .append(@obj_a = $.jumly ".object", "a")
- .append(@obj_b = $.jumly ".object", "b")
- @diag.appendTo $ "body"
-
- scenario "two objects in sequence diagram:0", ->
- it_behaves_as "two objects in sequence diagram"
- when_it "0:0, 0:0", ->
- obj_a.width(0).offset left:0
- obj_b.width(0).offset left:0
- then_it "0", ->
- expect(diag.preferredWidth()).toEqual 0
- ###
- NOTE: Usually, body element has initially margin about 8px.
- If you set the left of an object to zero with .offset(),
- css's left property goes to -8px. So some below scenarios are failed.
- ###
- scenario "two objects in sequence diagram:1", ->
- it_behaves_as "two objects in sequence diagram"
- when_it "0:0, 0:1", ->
- obj_a.width(0).offset left:0
- obj_b.width(0).offset left:1
- then_it "1", ->
- ## This is an so edge case ;)
- expect(diag.preferredWidth()).toEqual 0
-
- scenario "two objects in sequence diagram:2", ->
- it_behaves_as "two objects in sequence diagram"
- when_it "1:0, 1:1", ->
- obj_a.width(1).offset left:0
- obj_b.width(1).offset left:1
- then_it "2", ->
- expect(diag.preferredWidth()).toEqual 2
-
- scenario "two objects in sequence diagram:a", ->
- it_behaves_as "two objects in sequence diagram"
- when_it "88:0, 88:138", ->
- obj_a.width(88).offset left:0
- obj_b.width(88).offset left:(88 + 50)
- then_it "should be the distance b/w two", ->
- expect(diag.preferredWidth()).toEqual (88 + 50) + 88
-
- shared_behavior "four objects", ->
- it_behaves_as "two objects in sequence diagram", ->
- given "two objects in a diagram", ->
- diag.append(@obj_c = $.jumly ".object", "c")
- .append(@obj_d = $.jumly ".object", "d")
-
- scenario "four objects", ->
- it_behaves_as "four objects", ->
- when_it "", ->
- $.jumly.preferences(".sequence-diagram", $.jumly.preferences(".sequence-diagram:system-default"))
- when_it "composed", ->
- diag.appendTo $ "body"
- diag.compose()
- and_ "some parameters", ->
- @span = obj_b.offset().left - obj_a.outerRight()
- @objw = obj_a.width()
- then_it "preferredWidth", ->
- l = @obj_a.offset().left
- diag.preferredWidth().shouldBeGreaterThan 526
- and_ "left", ->
- (obj_a.position().left >= 0).shouldBeTruthy()
-
- scenario "private prefs", ->
- it_behaves_as "four objects", ->
- when_it "", ->
- diag.preferences($.jumly.preferences(".sequence-diagram:system-default"))
- when_it "composed", ->
- diag.appendTo $ "body"
- diag.compose()
- then_it "preferredWidth", ->
- l = @obj_a.offset().left
- diag.preferredWidth().shouldBeGreaterThan 526
- and_ "left", ->
- (obj_a.position().left >= 0).shouldBeTruthy()
-
View
36 lib/js/legacy/0.1.0/jumly.iconSpec.coffee
@@ -1,36 +0,0 @@
-description "icon", ->
- scenario "exact styles", ->
- given "an iconified .object", ->
- @obj = ($.jumly ".object", "Actor").iconify "actor",
- fillStyle : 'blue'
- strokeStyle: 'black'
- @diag = $.jumly(".sequence-diagram").append obj
- $("body").append diag
- {@styles} = obj.renderIcon()
- ## NOTE: following specs are based on the actual executed result.
- ## NOT expected base.
- then_it "fillStyle", ->
- styles.fillStyle.shouldBe 'rgb(255, 255, 255)'
- then_it "strokeStyle", ->
- styles.strokeStyle.shouldBe 'rgb(128, 128, 128)'
-
- scenario "icon style", ->
- given "some iconified .objects", ->
- @view = ($.jumly ".object", "") .iconify "view", strokeStyle:'blue', fillStyle:'#a0a0ff'
- @controller = ($.jumly ".object", "") .iconify "controller", strokeStyle:'orange', fillStyle:'yellow'
- @entity = ($.jumly ".object", "entity").iconify "entity", strokeStyle:'red', fillStyle:'#ffa0a0', shadowColor:'#aaa', shadowBlur:4
- @actor = ($.jumly ".object", "") .iconify "actor", strokeStyle:'green', fillStyle:'#a0ffa0'
- @view .appendTo $ "body"
- @controller.appendTo $ "body"
- @entity .appendTo $ "body"
- @actor .appendTo $ "body"
- @entity.find(".name").css border:"1px black solid"
- then_it "", ->
-
- scenario "exact styles", ->
- given "an iconified .object", ->
- @obj = ($.jumly ".object", "Actor").iconify "actor"
- $("body").append $.jumly(".sequence-diagram").append obj
- then_it "icon is centered about 20pixels", ->
- (obj.find(".name").offset().left + 20).shouldBeLessThan obj.find(".icon-container").offset().left
-
View
134 lib/js/legacy/0.1.0/jumly.identificationSpec.coffee
@@ -1,134 +0,0 @@
-description "uml.identification", ->
- description "jumly parameter -- identified string", ->
- f = $.jumly.normalize
- it "should accept a string", ->
- p = f "an object name"
- # {name:"an object name"}
- expect(p.id) .toBeUndefined()
- expect(p.name).toBe "an object name"
-
- it "should accept an identified string", ->
- p = f 1:"an object name"
- # {id:1, name:"an object name"}
- expect(p.id) .toBe 1
- expect(p.name).toBe "an object name"
-
- it "should accept a string with other parameters", ->
- p = f "an object name", width:100, height:200
- # {name:"an object name", width:100, height:200}
- expect(p.id) .toBeUndefined()
- expect(p.name) .toBe "an object name"
- expect(p.width) .toBe 100
- expect(p.height).toBe 200
-
- it "should accept an identified string with other parameters", ->
- p = f 2:"taro", length:180
- # {id:2, name:"taro", length:180}
- expect(p.id) .toBe 2
- expect(p.name) .toBe "taro"
- expect(p.length).toBe 180
-
- it "should accept an identified string with hex", ->
- p = f 0x10:"taro"
- expect(p.id).toBe 16
-
- it "should accept an identified string with string consisted of digit", ->
- p = f "1234":"taro"
- expect(p.id).toBe 1234
-
- it "should accept an jumly parameter", ->
- p = f id:"ID-3", name:"jiro", age:28
- # {id:2, name:"taro", length:180}
- expect(p.id) .toBe "ID-3"
- expect(p.name).toBe "jiro"
- expect(p.age) .toBe 28
-
- it "is undefined for identified strings more than two", ->
- p = f 1:"first", 2:"second"
-
- it "takes the property named as id", ->
- p = f 1:"first", 2:"second", id:"third"
- # {id:"third", 1:"first", 2:"second"}
- expect(p.id) .toBe "third"
- expect(p.name).toBeUndefined()
- expect(p[1]) .toBe "first"
- expect(p[2]) .toBe "second"
-
- it "should return null for number", ->
- p = f 1
- expect(p).toBe null
-
- it "should return null for array", ->
- p = f []
- expect(p).toBe null
-
- it "should return null for boolean", ->
- p = f 1
- expect(p).toBe null
-
- it "should return undefined for undefined", ->
- p = f undefined
- expect(p).toBe undefined
-
- it "should return null for null", ->
- p = f null
- expect(p).toBe null
-
- description "jumly parameter -- attributted string", ->
- it "should be composited as for attributed string", ->
- a = "Post a comment": use:[1, 2], extendee: a:1, b:2
- a["Post a comment"].use[0].shouldBe 1
- a["Post a comment"].extendee.b.shouldBe 2
-
- it "should be composited as identified string", ->
- a = 1234:"first-string": use:[1, 2], extendee: a:3, b:4
- a["1234"]["first-string"].use[0].shouldBe 1
-
- description "jumly parameter -- identified attributted string", ->
- f = $.jumly.normalize
-
- it "should return an array having three elements", ->
- a = {a:1, b:2, c:3}
- b = for k, v of a
- {k:k, v:v}
- b.length.shouldBe 3
-
- it "should return the last pair", ->
- a = {a:1, b:2, c:3}
- b = {k:k, v:v} for k, v of a
- expect(b.constructor is Array).toBeFalsy()
-
- it "should be identified", ->
- a = f 1234:"first-string", use:[1, 2], extendee: a:3, b:4
- a.id.shouldBe 1234
- a.name.shouldBe "first-string"
- a.use[0].shouldBe 1
- a.use[1].shouldBe 2
- a.extendee.a.shouldBe 3
- a.extendee.b.shouldBe 4
-
- it "should have name property for attributed string through normalize", ->
- f = $.jumly.normalize
- a = f "User": use:[1]
- a.name.shouldBe "User"
- expect(a["User"]).toBeUndefined()
- a.use[0].shouldBe 1
-
- description "identity return ID value or null", ->
- ident = $.jumly.identify
- it "should return 123 for 123", ->
- expect(ident id:123).toBe 123
- it "should return 555.01234 for 555.01234", ->
- expect(ident id:555.01234 ).toBe 555.01234
- it "should return 'abc'", ->
- expect(ident id:"abc").toBe 'abc'
- it "should return '345'", ->
- expect(ident id:->345).toBe 345
- it "should return null for them", ->
- expect(ident id:true).toBe null
- expect(ident id:false).toBe null
- expect(ident id:[]).toBe null
- expect(ident id:{}).toBe null
- expect(ident id:undefined).toBe null
- expect(ident id:null).toBe null
-
View
146 lib/js/legacy/0.1.0/jumly.objectSpec.coffee
@@ -1,146 +0,0 @@
-before = ->
- @diag = $.jumly(".sequence-diagram")
- .append(@obj_a = $.jumly(".object"))
- .append(@obj_b = $.jumly(".object"))
- .append(@obj_c = $.jumly(".object"))
- @diag.appendTo($("body"))
- @occurr_a = @obj_a.activate()
- @iact_a = $.jumly(@occurr_a.parents(".interaction"))[0]
- @iact_ab = @occurr_a.interact(@obj_b)
- @occurr_b = @iact_ab.gives(".occurrence").as(".actee")
- @iact_bc = @occurr_b.interact(@obj_c)
- @occurr_c = @iact_bc.gives(".occurrence").as(".actee")
- @fragment_ab = $.jumly(".fragment").enclose(@iact_ab)
-
-description 'object for sequence diagram', ->
- beforeEach -> before()
- # object
- it "should have an attr uml:property", ->
- obj_a.jprops().type.shouldBe ".object"
- it "should have attr() as a jQuery object", ->
- (typeof obj_a.attr).shouldBe "function"
- it "should have .object", ->
- obj_a.hasClass('object').shouldBe true
- it "should have activate", ->
- (typeof obj_a.activate).shouldBe 'function'
- it "is an occurrence activate() returns", ->
- obj_a.activate().hasClass('occurrence').shouldBe true
- it "should be capable where is left at for given object", ->
- (typeof obj_a.isLeftAt).shouldBe "function"
- it "should be capable where is right at for given object", ->
- (typeof obj_a.isRightAt).shouldBe "function"
- it "should be hidden for .icon", ->
- $(".object .icon", diag).length.shouldBe 0
- it "should have .icon by iconify", ->
- obj_a.iconify().find(".icon").css("display").shouldBe "inline"
- it "should have .iconified by iconify", ->
- obj_a.iconify().hasClass("iconified").shouldBe true
-
- # interaction
- it "should have an attr uml:property", ->
- iact_a.jprops().type.shouldBe ".interaction"
- it "should have nothing as owner", ->
- (iact_a.gives(".object") is null).shouldBe true
- it "shouldn't have a occurrence of actor object", ->
- (iact_a.gives(".occurrence").as(".actor") is null).shouldBe true
- it "should have a occurrence of actee object", ->
- expect(iact_a.gives(".occurrence").as(".actee")).toBe occurr_a
- it "should return false for iact_a", ->
- iact_a.is_to_itself().shouldBe false
- it "should return false for iact_ab", ->
- iact_ab.is_to_itself().shouldBe false
-
- it "should have an actor", ->
- (iact_a.gives(".occurrence").as(".actor") is null).shouldBe true
- it "should have an actee", ->
- expect(iact_a.gives(".occurrence").as(".actee").gives(".object")).toBe obj_a
- it "shouldn't be contained in an interaction created by activate() ", ->
- $(".message", iact_a).length.shouldBe 2
- it "should be capable to return <<return>>", ->
- expect(iact_a.reply()).toBe iact_a
- it "should fragment", ->
- iact_a.fragment().hasClass("fragment").shouldBe true
-
- # occurrence
- it "should have an attr uml:property", ->
- occurr_a.jprops().type.shouldBe ".occurrence"
- it "should have an attr uml:property", ->
- occurr_b.jprops().type.shouldBe ".occurrence"
- #NOTE: Can enable by improving 'interact'.
- #it "should have an interaction as actor", {'occurr_a.gives(".interaction").as("actor") === iact_a'.js_true()}
- it "should have an object as owner", ->
- expect(occurr_a.gives(".object")).toBe obj_a
- it "shouldn't be initially on a occurrence", ->
- occurr_a.isOnOccurrence().shouldBe false
- it "should return null for occurrence which itself is on", ->
- expect(occurr_a.parentOccurrence()).toBe null
- it "should return 0 for shift to parent", ->
- occurr_a.shiftToParent().shouldBe 0
- it "should return the nearest occurrence for given object", ->
- expect(occurr_c.preceding(obj_a)).toBe occurr_a
- # message
- it "should have an attr uml:property", ->
- diag.find(".message").jprops().type.shouldBe ".message"
- it "should be held by an interaction", ->
- expect(diag.$(".message")[0].gives(".interaction")).toBe iact_ab
- it "should be capable to point the direction", ->
- (typeof diag.$(".message")[0].isToward).shouldBe "function"
- it "should be capable whether is toward right", ->
- (typeof diag.$(".message")[0].isTowardRight).shouldBe "function"
- it "should be capable whether is toward left", ->
- (typeof diag.$(".message")[0].isTowardLeft).shouldBe "function"
-
- # fragment
- it "should have an attr uml:property", ->
- diag.$0(".fragment").jprops().type.shouldBe ".fragment"
- it "should be created", ->
- diag.$(".fragment")[0].hasClass("fragment").shouldBe true
- it "should have class 'fragment'", ->
- fragment_ab.hasClass("fragment").shouldBe true
- it "should have enclose()", ->
- (typeof fragment_ab.enclose).shouldBe "function"
-
- # ref
- it "should have an attr uml:property", ->
- $.jumly(".ref").jprops().type.shouldBe ".ref"
- it "should have class 'ref'", ->
- $.jumly(".ref").hasClass("ref").shouldBe true
- it "shodld have preferredWidth", ->
- (typeof $.jumly(".ref").preferredWidth).shouldBe "function"
-
- # diag.am
- it "should have an attr uml:property", ->
- diag.jprops().type.shouldBe ".sequence-diagram"
- it "should be capable to find with selector", ->
- expect(diag.$(".interaction")[0].gives(".occurrence").as(".actee")).toBe occurr_a
- it "should return nothing for compose", ->
- diag.compose().hasClass("sequence-diagram").shouldBe true
- it "should return itself for compose()", ->
- expect(diag).toBe diag.compose()
- it "should have preferences", ->
- (typeof diag.preferences).shouldBe "function"
- it "should be preferences have WIDTH", ->
- (typeof diag.preferences().WIDTH).shouldBe "number"
- it "should be preferences have HEIGHT", ->
- (typeof diag.preferences().HEIGHT).shouldBe "number"
- it "should have preferredWidth", ->
- expect(typeof diag.preferredWidth).toBe "function"
-
- # diag.am.$0
- it 'should return the 1st object', ->
- expect(diag.$0(".object")).toBe obj_a
- it 'should return the 3rd object', ->
- expect(diag.$0(".object:eq(2)")).toBe obj_c
-
- # $.jumly
- it "should return the same instance for diag", ->
- expect($.jumly($("body > .diagram:last")[0])[0][0] is diag[0]).toBe true
- it "should have .diagram", ->
- $.jumly($("body > .diagram"))[0].hasClass("diagram").shouldBe true
- it 'should be improved at accessibility to instances using $.jumly', ->
-
- it "should return the same object for selector", ->
- expect($.jumly($(".occurrence", iact_a))[0]).toBe occurr_a
- it 'should store jQuery instance in self()', ->
- expect(occurr_b.self()).toBe occurr_b
-
View
78 lib/js/legacy/0.1.0/jumly.propertySpec.coffee
@@ -1,78 +0,0 @@
-description "jprops", ->
- u = $.jumly
- shared_scenario "stereotype CRUD, Create/Read", ->
- given "an object", ->
- @a = u ".object"
- @b = u ".object"
- when_it "add a stereotype", ->
- @a.addClass "abstract"
- then_it "@a has the stereotype", ->
- # LEGACY: @a.jprops().stereotypes().length.shouldBe 1
- # LEGACY: @a.hasStereotype("abstract").shouldBeTruthy()
- @a.hasClass("abstract").shouldBeTruthy()
- then_it "@b doesn't have stereotype", ->
- @b.jprops().stereotypes().length.shouldBe 0
-
- shared_scenario "stereotype CRUD, Add more", ->
- it_behaves_as "stereotype CRUD, Create/Read"
- when_it "add a stereotype", ->
- @a.addClass "mutable"
- then_it "@a has the multiple stereotypes()", ->
- #@a.jprops().stereotypes().length.shouldBe 2
- and_ ->
- # LEGACY: @a.hasStereotype("abstract").shouldBeTruthy()
- @a.hasClass("abstract").shouldBeTruthy()
- and_ ->
- # LEGACY: @a.hasStereotype("mutable").shouldBeTruthy()
- @a.hasClass("mutable").shouldBeTruthy()
-
-
- shared_scenario "found and create", ->
- given "some objects", ->
- @diag = $.jumly ".sequence-diagram"
- diag.found "A", ->
- @create "B"
- @a = @diag.jprops()
- @b = @diag.A.jprops()
- @c = @diag.B.jprops()
- @d = @diag.find(".message:last").self().jprops()
- # then_it "has name for @a", -> expect(@a.name).toBeDefined()
- # and_ "has name for @b", -> expect(@b.name).toBeDefined()
- # and_ "has name for @c", -> expect(@c.name).toBeDefined()
- # and_ "has name for @d", -> expect(@d.name).toBeDefined()
- #then_it "has name for @a", -> expect(@a.name).toBeDefined()
- # and_ "has name for @b", -> expect(@b.name).toBe "A"
- # and_ "has name for @c", -> expect(@c.name).toBe "B"
- #and_ "has name for @d", -> expect(@d.name).toBeDefined()
- #then_it "has stereotypes() for @a", -> expect(@a.stereotypes()).toBeDefined()
- #and_ "has stereotypes() for @b", -> expect(@b.stereotypes()).toBeDefined()
- #and_ "has stereotypes() for @c", -> expect(@c.stereotypes()).toBeDefined()
- #and_ "has stereotypes() for @d", -> expect(@d.stereotypes()).toBeDefined()
- #then_it "has stereotypes() for @a", -> expect(0).toBe @a.stereotypes().length
- #and_ "has stereotypes() for @b", -> expect(0).toBe @b.stereotypes().length
- #and_ "has stereotypes() for @c", -> expect(0).toBe @c.stereotypes().length
- #and_ "has stereotypes() for @d", -> expect(1).toBe @d.stereotypes().length
- # then_it "has type for @a", -> expect(@a.type).toBeDefined()
- # and_ "has type for @b", -> expect(@b.type).toBeDefined()
- # and_ "has type for @c", -> expect(@c.type).toBeDefined()
- # and_ "has type for @d", -> expect(@d.type).toBeDefined()
- # then_it "has the type @a", -> expect(".sequence-diagram").toBe @a.type
- # and_ "has the type @b", -> expect(".object") .toBe @b.type
- # and_ "has the type @c", -> expect(".object") .toBe @c.type
- # and_ "has the type @d", -> expect(".message") .toBe @d.type
-
- description "streotype", ->
- it "has stereotype property", ->
- diag = $.jumly ".sequence-diagram"
- diag.found "A", -> @create "B"
- msg = (diag.find ".message:last").self()
- (msg.hasClass "create").shouldBeTruthy()
- #msg.jprops().stereotypes().length.shouldBe 1
-
- description "name", ->
- it "has name property", ->
- diag = $.jumly ".sequence-diagram"
- diag.found "A", -> @message "call", "B"
- msg = (diag.find ".message:last").self()
- #msg.jprops().name.shouldBe "call"
-
View
442 lib/js/legacy/0.1.0/jumlySpec.coffee
@@ -1,442 +0,0 @@
-description "jumly", ->
- shared_behavior "create an object and refers with 2ways", ->
- given "an object out from jumly()", ->
- @diagram = $.jumly(".sequence-diagram")
- @obj_a = $.jumly(".object")
- @obj_b = $.jumly(".object")
-
- when_it "append it into body", ->
- diagram.append obj_a
-
- and_ "get it again with jQuery selector", ->
- @a0 = $.jumly($(".object:last", diagram)[0])
-
- and_ "get also it as jQueery object", ->
- @a1 = $.jumly($(".object:last", diagram))
-
- scenario "identification for single object (guarantee 'create an object and refers with 2ways')", ->
- it_behaves_as "create an object and refers with 2ways"
- then_it "a0 has length which is number", ->
- (typeof a0.length == "number").shouldBe true
-
- and_ "a1 has length which is number, too", ->
- (typeof a1.length == "number").shouldBe true
-
- and_ "it equals to the given one", ->
- (obj_a == a0[0]).shouldBe true
-
- and_ "it also equals to another one", ->
- (obj_a == a1[0]).shouldBe true
-
- and_ "the length is 1", ->
- (1 == a0.length).shouldBe true
-
- and_ "also 1, too", ->
- (1 == a1.length).shouldBe true
-
- and_ "a0 has each method", ->
- (typeof a0.each == "function").shouldBe true
-
- and_ "a1 has each method", ->
- (typeof a1.each == "function").shouldBe true
-
- shared_behavior "create 2nd object in the diagram", ->
- it_behaves_as "create an object and refers with 2ways"
- when_it "creating 2nd object", ->
- diagram.append obj_b.hide()
-
- and_ "selecting multiple objects", ->
- @objs = $.jumly($(".object", diagram))
-
- scenario "identification for multiple objects (guarantee 'create 2nd object in the diagram')", ->
- it_behaves_as "create 2nd object in the diagram"
- then_it "the length is 2", ->
- objs.length.shouldBe 2
-
- and_ "1st is obj_a", ->
- (obj_a == objs[0]).shouldBe true
-
- and_ "2nd is obj_b", ->
- (obj_b == objs[1]).shouldBe true
-
- scenario "with selector of jQuery", ->
- it_behaves_as "create 2nd object in the diagram"
- when_it "selecting an object", ->
- @a0 = diagram.$(".object:eq(0)")
-
- and_ "selecting another object", ->
- @a1 = diagram.$(".object:eq(1)")
-
- and_ "selecting the last object", ->
- @last = diagram.$(".object:last")
-
- then_it "the 1st one's len is 1", ->
- (a0.length == 1).shouldBe true
-
- and_ "the 2nd one's len is 1", ->
- (a1.length == 1).shouldBe true
-
- and_ "the last's len is 1", ->
- (last.length == 1).shouldBe true
-
- and_ "the 1st one equals obj_a", ->
- (a0[0] == obj_a).shouldBe true
-
- and_ "the 2nd one equals obj_b", ->
- (a1[0] == obj_b).shouldBe true
-
- and_ "the last equals obj_b", ->
- (last[0] == obj_b).shouldBe true
-
- shared_behavior "activating an occurrence", ->
- given "an .object and occurrence", ->
- @diagram = $.jumly(".sequence-diagram").append(@obj_a = $.jumly(".object"))
- @occurr_a = obj_a.activate()
- $("body").append diagram
-
- scenario ".object referred from .occurrence (ensure 'activating an occurrence')", ->
- it_behaves_as "activating an occurrence"
- then_it "the .object can be referred with a method", ->
- (occurr_a.gives(".object") == obj_a).shouldBe true
-
- then_it "not null", ->
- (occurr_a.gives(".object") != null).shouldBe true
-
- scenario "returning null nodes if not found", ->
- it_behaves_as "activating an occurrence"
- then_it "returns null", ->
- (occurr_a.gives(".foobar") is null).shouldBe true
-
- scenario "interactions for the 1st occurrence", ->
- it_behaves_as "activating an occurrence"
- given "the 1st interaction", ->
- @iact_a = $.jumly($(".interaction:eq(0)", diagram))[0]
-
- then_it "no .interaction is as .actor", ->
- (iact_a.gives(".occurrence").as(".actor") == null).shouldBe true
-
- then_it ".interaction is as .actee", ->
- (iact_a.gives(".occurrence").as(".actee") == occurr_a).shouldBe true
-
- shared_behavior "an interacting", ->
- it_behaves_as "activating an occurrence"
- given "an new .object", ->
- @obj_b = $.jumly(".object")
-
- and_ "an .interaction", ->
- @iact_ab = occurr_a.interact(obj_b)
-
- and_ "an new .occurrence which is created by interact", ->
- @occurr_b = $.jumly(iact_ab.find(".occurrence"))[0]
-
- and_ "an new .message which is created by interact", ->
- @msg_ab = $.jumly(iact_ab.find(".message"))[0]
-
- scenario "an .interaction with the .object and .occurrence (ensure 'an interacting')", ->
- it_behaves_as "an interacting"
- then_it "the .interaction gives the 1st .object", ->
- (iact_ab.gives(".object").as(".actor") == obj_a).shouldBe true
-
- and_ "the .interaction gives the 2nd .object", ->
- (iact_ab.gives(".object").as(".actee") == obj_b).shouldBe true
-
- and_ "the .interaction gives the .occurrence as .actor", ->
- (iact_ab.gives(".occurrence").as(".actor") == occurr_a).shouldBe true
-
- and_ "the .interaction gives a new .occurrence as .actee", ->
- (iact_ab.gives(".occurrence").as(".actee") == occurr_b).shouldBe true
-
- and_ "the .interaction gives the .message", ->
- (iact_ab.gives(".message") == msg_ab).shouldBe true
-
- then_it "the .message gives the .interaction", ->
- (msg_ab.gives(".interaction") == iact_ab).shouldBe true
-
- and_ "the .message gives the .occurrence of .actee through the interaction", ->
- (msg_ab.gives(".interaction").gives(".occurrence").as(".actee") == occurr_b).shouldBe true
-
- then_it "the new .occurrence gives the new 2nd .object", ->
- (occurr_b.gives(".object") == obj_b).shouldBe true
-
- scenario "lifeline giving/taking", ->
- it_behaves_as "activating an occurrence"
- when_it "composing", ->
- diagram.compose()
-
- and_ "taking a new lifeline", ->
- @ll_a = $.jumly(diagram.find(".lifeline:eq(0)"))[0]
-
- then_it "the object gives/of the lifeline of itself", ->
- (diagram.gives(".lifeline").of(obj_a) == ll_a).shouldBe true
-
- then_it "not null", ->
- (ll_a != null).shouldBe true
-
- then_it "the object gives/of empty array for unrelated object", ->
- (diagram.gives(".lifeline").of($("")).length == 0).shouldBe true
-
- shared_behavior "create 2 divs into a diagram", ->
- given "a diagrma and 2 plain divs", ->
- @diagram = $.jumly(".sequence-diagram").append("<div>").append("<div>")
-
- scenario "normal DOM node selection (guarantee 'create 2 divs into a diagram')", ->
- it_behaves_as "create 2 divs into a diagram"
- when_it "selecting all divs", ->
- @objs = $.jumly($("div", diagram))
-
- then_it "length is 2", ->
- objs.length.shouldBe 2
-
- but_ "1st slot is null", ->
- (objs[0] == null).shouldBe true
-
- and_ "2nd slot is null", ->
- (objs[1] == null).shouldBe true
-
- shared_behavior "3 objects and simple interactions", ->
- given "a diagram", ->
- @diagram = $.jumly(".sequence-diagram").append(@obj_a = $.jumly(".object")).append(@obj_b = $.jumly(".object")).append(@obj_c = $.jumly(".object"))
- @ll_a = obj_a.activate()
- @ll_b = ll_a.interact(obj_b).gives(".occurrence").as(".actee")
- @ll_c = ll_b.interact(obj_c).gives(".occurrence").as(".actee")
-
- scenario "preceding of occurrence", ->
- it_behaves_as "3 objects and simple interactions"
- then_it "c for b is b", ->
- (ll_c.preceding(obj_b) == ll_b).shouldBe true
-
- and_ "c for a is a", ->
- (ll_b.preceding(obj_a) == ll_a).shouldBe true
-
- and_ "a for a is null", ->
- (ll_a.preceding(obj_a) == null).shouldBe true
-
- and_ "b for b is null", ->
- (ll_b.preceding(obj_b) == null).shouldBe true
-
- and_ "c for c is null", ->
- (ll_c.preceding(obj_c) == null).shouldBe true
-
- and_ "b for c is null", ->
- (ll_b.preceding(obj_c) == null).shouldBe true
-
- narrative "fundamental capability"
- shared_behavior "create an object", ->
- given "an object", ->
- @obj_a = $.jumly(".object")
- .name("foo")
- .stereotype("bar")
-
- scenario "guarantee 'create an object' for getter", ->
- it_behaves_as "create an object"
- then_it "the name is 'foo'", ->
- @n = obj_a.name()
- n.shouldBe "foo"
-
- and_ "the stereotype is 'bar'", ->
- obj_a.stereotype().shouldBe "bar"
-
- and_ "uml:property returns an object having all attributes", ->
- @all = obj_a.jprops()
-
- and_ "name", ->
- all.name.shouldBe "foo"
-
- and_ "stereotype", ->
- all.stereotype.shouldBe "bar"
-
- scenario "guarantee 'create an object' for setter", ->
- it_behaves_as "create an object"
- when_it "set name", ->
- obj_a.name "fiz"
-
- and_ "set stereotype", ->
- obj_a.stereotype "buz"
-
- then_it "the name is 'fiz'", ->
- obj_a.name().shouldBe "fiz"
-
- and_ "the stereotype is 'buz'", ->
- obj_a.stereotype().shouldBe "buz"
-
- and_ "uml:property returns an object having all attributes", ->
- @all = obj_a.jprops()
-
- and_ "name", ->
- all.name.shouldBe "fiz"
-
- and_ "stereotype", ->
- all.stereotype.shouldBe "buz"
-
- scenario "empty string for name, stereotype", ->
- it_behaves_as "create an object"
- when_it "sets empty string", ->
- obj_a.name ""
- obj_a.stereotype ""
-
- then_it "returns empty string", ->
- (obj_a.name() == "").shouldBe true
-
- and_ "too", ->
- (obj_a.stereotype() == "").shouldBe true
-
- scenario "undefined for name, stereotype", ->
- it_behaves_as "create an object"
- when_it "sets undefined", ->
- obj_a.name undefined
- obj_b.stereotype undefined
-
- then_it "makes no effects", ->
- (obj_a.name() == "foo").shouldBe true
-
- and_ "too", ->
- (obj_a.stereotype() == "bar").shouldBe true
-
- scenario "null for name, stereotype", ->
- it_behaves_as "create an object"
- when_it "sets null", ->
- obj_a.name null
- obj_a.stereotype null
-
- then_it "return null", ->
- (obj_a.name() == null).shouldBe true
-
- and_ "too", ->
- (obj_a.stereotype() == null).shouldBe true
-
- scenario "partial update", ->
- it_behaves_as "create an object"
- when_it "set name", ->
- obj_a.stereotype("baz")
-
- then_it "makes no effects", ->
- (obj_a.name() == "foo").shouldBe true
-
- and_ "too", ->
- (obj_a.stereotype() == "baz").shouldBe true
-
- narrative "stereotype"
- scenario "stereotype for .message in data", ->
- given "an object and an message", ->
- @obj_a = $.jumly(".object")
- @iact_aa = obj_a.activate().interact(obj_a)
- @msg_a = $.jumly($(".message:eq(0)", iact_aa))[0]
-
- when_it "set stereotype to obj_a", ->
- obj_a.stereotype "actor"
-
- and_ "set stereotype to msg_a", ->
- msg_a.stereotype "asynchronous"
-
- then_it "the message has .asynchronous class", ->
- msg_a.hasClass("asynchronous").shouldBe true
-
- shared_behavior "four messages", ->
- given "messages", ->
- @diagram = $.jumly(".sequence-diagram").append(obj_a = $.jumly(".object"))
- diagram.appendTo $("body")
- obj_a.activate().interact(obj_a).gives(".occurrence").as(".actee").interact(obj_a).gives(".occurrence").as(".actee").interact(obj_a).gives(".occurrence").as(".actee").destroy obj_a
- @msg_a0 = diagram.$0(".message:eq(0)")
- @msg_a1 = diagram.$0(".message:eq(1)")
- @msg_a2 = diagram.$0(".message:eq(2)")
- @msg_a3 = diagram.$0(".message:eq(3)")
-
- scenario "message with stereotype method", ->
- it_behaves_as "four messages"
- when_it "give stereotype", ->
- msg_a0.stereotype "create"
- msg_a1.stereotype "asynchronous"
- msg_a2.stereotype "synchronous"
- msg_a3.stereotype "destroy"
-
- then_it "msg_a0 has .create", ->
- msg_a0.hasClass("create").shouldBe true
-
- then_it "msg_a1 has .asynchronous", ->
- msg_a1.hasClass("asynchronous").shouldBe true
-
- then_it "msg_a2 has .synchronous", ->
- msg_a2.hasClass("synchronous").shouldBe true
-
- then_it "msg_a3 has .destroy", ->
- msg_a3.hasClass("destroy").shouldBe true
-
- scenario "stereotype for interaction", ->
- it_behaves_as "four messages"
- when_it "give stereotype", ->
- diagram.$0 ".interaction:eq(0)"
- diagram.$0(".interaction:eq(1)").stereotype "create"
- diagram.$0(".interaction:eq(2)").stereotype "asynchronous"
- diagram.$0(".interaction:eq(3)").stereotype "synchronous"
- diagram.$0(".interaction:eq(4)").stereotype "destroy"
-
- then_it "msg_a0 has .create", ->
- msg_a0.hasClass("create").shouldBe true
-
- then_it "msg_a1 has .asynchronous", ->
- msg_a1.hasClass("asynchronous").shouldBe true
-
- then_it "msg_a2 has .synchronous", ->
- msg_a2.hasClass("synchronous").shouldBe true
-
- then_it "msg_a3 has .destroy", ->
- msg_a3.hasClass("destroy").shouldBe true
-
- then_it "obj_a is not affected", ->
- (obj_a.attr("class") == "object").shouldBe true
-
- scenario "__proto__", ->
- given "some objects having different type each other", ->
- @obj = $.jumly(".object")
- @msg = $.jumly(".message")
- @iact = $.jumly(".interaction")
-
- then_it "they are not equal, obj & msg", ->
- (obj.__proto__ == msg.__proto__).shouldBe false
-
- and_ "__proto__ b/w msg & iact", ->
- (msg.__proto__ == iact.__proto__).shouldBe false
-
- and_ "__proto__ b/w iact & obj", ->
- (iact.__proto__ == obj.__proto__).shouldBe false
-
- scenario "uml object selected by selector", ->
- it_behaves_as "create an object and refers with 2ways"
- when_it "select the 2nd", ->
- @b1 = diagram.find(".object:last")
- ## wrapping is needed, it's very hard, so pending.
- xthen_it "has gives", ->
- (typeof b1.gives).shouldBe "function"
-
- evalScript = JUMLY.evalHTMLScriptElement
- description "script tag", ->
- #@disabled: v0.1.0 feature.
- xit 'should TENTATIVELY change before-behavior', ->
- prefs = $.jumly[':preferences'].run_script
- save = prefs.before_compose
- prefs.before_compose = (diag, target) -> diag.prependTo target
-
- script = $("<script>").attr(type:"text/jumly-usecase-diagram", "target-id":"we-can-change-a-manupilator").html """
- @usecase(id:1) "an usecase"
- @actor "user":use:[1]
- """
- target = $("<div>").attr(id:"we-can-change-a-manupilator")
- .append("<div>hello</div>")
- $("body").append target
-
- diag = evalScript script
- expect(target.find("*:eq(0)").hasClass "diagram").toBeTruthy() ## diag is prepended in the target.
-
- prefs.before_compose = save
-
- description "type of script, mime-type", ->
- it 'should accept text/jumly+<type>', ->
- script = $("<script>").attr(type:"text/jumly+usecase", "target-id":"script-tag-mime-type").html """
- @usecase 1:"an usecase"
- @actor "user":use:[1]
- """
- target = $("<div>").attr(id:"script-tag-mime-type")
- .append("<div>hello</div>")
- $("body").append target
- diag = evalScript script
- expect(target.find("*:eq(0)").hasClass "diagram").toBeTruthy() ## diag is prepended in the target.
View
1,030 lib/js/legacy/0.1.0/sequence-diagramSpec.coffee
@@ -1,1030 +0,0 @@
-u = $.jumly
-description "sequence-diagram", ->
-
- description "width", ->
-
- scenario "of single object, which is includeing the horizontal thickness of box-shadow", ->
- given "an object", ->
- @diag = u ".sequence-diagram"
- @diag.css border:"black solid 1px"
- @ctxt = diag.found "Something"
- when_it "give shadow and compose", ->
- $(["", "-webkit-", "-moz-", "-o-"]).each (i, e) -> diag.find(".object").css(e + "box-shadow", "10px 5px 5px #080")
- ctxt.compose $ "body"
- then_it "including the thickness of shadow", ->
- a = diag.width()
- b = diag.find(".object").width()
- a.shouldBeGreaterThan b
-
-
- shared_behavior "create two objects", ->
- given "two objects -- a, b", ->
- $.extend jQuery::,
- left: ->
- @offset().left
-
- hcenter: ->
- @offset().left + @width() / 2
-
- left_is_in: (r) ->
- r[0] < @left() and @left() < r[1]
-
- @_in_ = (a, x, b) ->
- a < x and x < b
-
- @a = $.jumly(".object")
- @b = $.jumly(".object")
-
- shared_behavior "activate a", ->
- it_behaves_as "create two objects"
- when_it "activate one", ->
- @occurrence_a = a.activate()
-
- scenario "guarantee 'activation a'", ->
- it_behaves_as "activate a"
- then_it "occurrence.owner returns a", ->
- (occurrence_a.gives(".object") == a).shouldBe true
-
- and_ "the occurrence is not on a occurrence", ->
- (not occurrence_a.isOnOccurrence()).shouldBe true
-
- and_ "parent occurrence is null", ->
- (occurrence_a.parentOccurrence() == null).shouldBe true
-
- shared_behavior "a interacts to b", ->
- it_behaves_as "activate a"
- when_it "interact with another and returns an interaction", ->
- @iact_a_b = occurrence_a.interact(b)
-
- scenario "guarantee 'a interacts to b'", ->
- it_behaves_as "a interacts to b"
- then_it "the interaction has a occurrence of the actor", ->
- (iact_a_b.gives(".occurrence").as(".actor") == occurrence_a).shouldBe true
-
- and_ "the owner of the actor's occurrence equal to a", ->
- (iact_a_b.gives(".occurrence").as(".actor").gives(".object") == a).shouldBe true
-
- and_ "the owner of the actee's occurrence equal to b", ->
- (iact_a_b.gives(".occurrence").as(".actee").gives(".object") == b).shouldBe true
-
- and_ "the interaction is not to itself", ->
- iact_a_b.is_to_itself().shouldBe false
-
- shared_behavior "interacting among 3 objects", ->
- it_behaves_as "a interacts to b"
- given "a new object -- c", ->
- @c = $.jumly(".object")
-
- when_it "interacting from the occurrence of b to c", ->
- @iact_b_c = iact_a_b.gives(".occurrence").as(".actee").interact(c)
-
- scenario "guarantee 'interacting among 3 objects'", ->
- it_behaves_as "interacting among 3 objects"
- then_it "the 2nd interaction has the occurrence for c", ->
- (iact_b_c.gives(".occurrence").as(".actee").gives(".object") == c).shouldBe true
-
- and_ "the new interaction has the occurrence for b, too", ->
- (iact_b_c.gives(".occurrence").as(".actor").gives(".object") == b).shouldBe true
-
- shared_behavior "interacting back to a from c over b", ->
- it_behaves_as "interacting among 3 objects"
- when_it "interacting from c to a", ->
- @iact_c_a = iact_b_c.gives(".occurrence").as(".actor").interact(a)
-
- scenario "guarantee 'interacting back to a from c over b'", ->
- it_behaves_as "interacting back to a from c over b"
- then_it "the new interaction has the lineline for a", ->
- (iact_c_a.gives(".occurrence").as(".actee").gives(".object") == a).shouldBe true
-
- and_ "it differs to the 1st occurrence for a", ->
- (iact_c_a.gives(".occurrence").as(".actee") != occurrence_a).shouldBe true
-
- shared_behavior "message to itself for a", ->
- when_it "interacting to itself", ->
- @iact_a_a = iact_c_a.gives(".occurrence").as(".actee").interact(a)
-
- scenario "guarantee 'message to itself for a'", ->
- it_behaves_as "message to itself for a"
- then_it "owner of both occurrence is same", ->
- (iact_a_a.gives(".occurrence").as(".actor").gives(".object") == iact_a_a.gives(".occurrence").as(".actee").gives(".object")).shouldBe true
-
- but_ "occurrence instance are not same", ->
- (iact_a_a.gives(".occurrence").as(".actor") != iact_a_a.gives(".occurrence").as(".actee")).shouldBe true
-
- and_ "the interaction.itself is true", ->
- iact_a_a.is_to_itself().shouldBe true
-
- description "sequence diagram DOM structure", ->
-
- scenario "a sequence starts from an unknown event source", ->
- given "an object", ->
- @obj_a = $.jumly(".object")
-
- when_it "the soruce interacts to the object", ->
- @ll_a = obj_a.activate()
-
- then_it "the occurrence is contained in an interaction", ->
- @iact = $.jumly(ll_a.parents(".interaction"))[0]
- iact.length.shouldBe 1
-
- and_ "the source object for the interaction is null", ->
- (iact.gives(".occurrence").as(".actor") == null).shouldBe true
-
- but_ "isn't undefined", ->
- (iact.gives(".occurrence").as(".actor") != undefined).shouldBe true
-
- and_ "the interaction having the occurrence contains 1 occurrence", ->
- iact.find(".occurrence").length.shouldBe 1
-
- and_ "the destination object for the interaction is the activated object", ->
- (iact.gives(".occurrence").as(".actee").gives(".object") == obj_a).shouldBe true
-
- shared_behavior "create an object and activate it", ->
- given "a sequence-diagram", ->
- @diagram = $.jumly(".sequence-diagram")
-
- and_ "an object", ->
- @obj_a = $.jumly(".object")
-
- when_it "add the object into the diagram", ->
- diagram.append obj_a
-
- and_ "the .object is activated and a occurrence is generated", ->
- @ll_a = obj_a.activate()
-
- scenario "guarantee 'create an object and activate it'", ->
- it_behaves_as "create an object and activate it"
- then_it "an interaction to the object is contained by the diagram", ->
- $("> .interaction", diagram).length.shouldBe 1
-
- and_ "a occurrence are contained by the diagram", ->
- $("> .interaction .occurrence", diagram).length.shouldBe 1
-
- and_ "the occurrence doesn't have any interaction", ->
- $("> .interaction .occurrence .interaction", diagram).length.shouldBe 0
-
- shared_behavior "create two objects, activate one of them and interact b/w 2", ->
- it_behaves_as "create an object and activate it"
- given "2nd object", ->
- @obj_b = $.jumly(".object")
-
- and_ "add the both into the diagram", ->
- diagram.append obj_b
-
- when_it "interacts to another one", ->
- @iact_a_b = ll_a.interact(obj_b)
-
- scenario "guarantee 'create two objects, activate one of them and interact b/w 2'", ->
- it_behaves_as "create two objects, activate one of them and interact b/w 2"
- then_it "there is an interaction just under the diagram", ->
- $("> .interaction", diagram).length.shouldBe 1
-
- and_ "there are two interactions in the diagram", ->
- $(".interaction", diagram).length.shouldBe 2
-
- and_ "the occurrence has already been contained in the diagram", ->
- $("> .interaction .occurrence", diagram).length.shouldBe 2
-
- and_ "there is a message in the interaction", ->
- $("> .interaction .message", diagram).length.shouldBe 1
-
- and_ "the total number of interactions", ->
- $.jumly($(".interaction", diagram)).length.shouldBe 2
-
- and_ "the number of interactions under occurrence", ->
- $.jumly($(".occurrence .interaction", diagram)).length.shouldBe 1
-
- scenario "guarantee DOM structure of 'create an object and activate it'", ->
- it_behaves_as "create an object and activate it"
- then_it "object = 1", ->
- diagram.find("> .object").length.shouldBe 1
-
- and_ "interaction = 1", ->
- diagram.find("> .interaction").length.shouldBe 1
-
- and_ "occurrence = 1", ->
- diagram.find("> .interaction > .occurrence").length.shouldBe 1
-
- and_ "message = 0", ->
- diagram.find("> .message").length.shouldBe 0
-
- and_ "diagram, object", ->
- diagram.find("> :eq(0)").hasClass("object").shouldBe true
-
- and_ "diagram, interaction", ->
- diagram.find("> :eq(1)").hasClass("interaction").shouldBe true
-
- and_ "diagram, occurrence", ->
- diagram.find("> .interaction > :eq(0)").hasClass("occurrence").shouldBe true
-
- scenario "guarantee DOM composition of 'create an object and activate it' by YAML", ->
- it_behaves_as "create an object and activate it"
- then_it "The diagram has 2 children, .object and .interaction, and the interaction has a occurrence", ->
- diagram.find("> .object").expect().lengthIs(1).end().find("> .interaction").expect().lengthIs(1).find("> .occurrence").expect().lengthIs 1
-
- scenario "guarantee DOM composition of 'create two objects, activate one of them and interact b/w 2'", ->
- it_behaves_as "create two objects, activate one of them and interact b/w 2"
- then_it "the composition below", ->
- diagram.find("> .object:eq(0)").expect().lengthIs(1).end().find("> .interaction").expect().lengthIs(1).find("> .occurrence").expect().lengthIs(1).find("> .interaction").expect().lengthIs(1).find("> .message").expect().lengthIs(1).end().find("> .occurrence").expect().lengthIs(1).end().end().end().end().find("> .object:eq(1)").expect().lengthIs 1
-
- scenario "valid occurrences", ->
- given "a diagram and 3 objects", ->
- @diagram = $.jumly(".sequence-diagram").append(@obj_a = $.jumly(".object")).append(@obj_b = $.jumly(".object")).append(@obj_c = $.jumly(".object"))
-
- when_it "activating an object of two", ->
- @ll_a = obj_a.activate()
-
- and_ "obj_a interact to obj_b", ->
- @iact_a_b = ll_a.interact(obj_b)
- @ll_b = iact_a_b.gives(".occurrence").as(".actee")
-
- and_ "obj_b interact to obj_c", ->
- @iact_b_c = ll_b.interact(obj_c)
- @ll_c = iact_b_c.gives(".occurrence").as(".actee")
-
- and_ "selecting interactions under occurrence", ->
- @iacts = $.jumly($(".occurrence .interaction", diagram))
-
- then_it "ll_a has the diagram as the parent", ->
- ll_a.parents(".diagram").length.shouldBe 1
-
- then_it "number of interactions is 2", ->
- (iacts.length == 2).shouldBe true
-
- and_ "the 1st is iact_a_b", ->
- (iacts[0] == iact_a_b).shouldBe true
-
- and_ "the 2nd is iact_b_c", ->
- (iacts[1] == iact_b_c).shouldBe true
-
- and_ "the 1st has ll_a", ->
- (iacts[0].gives(".occurrence").as(".actor") == ll_a).shouldBe true
-
- and_ "ll_b", ->
- (iacts[0].gives(".occurrence").as(".actee") == ll_b).shouldBe true
-
- and_ "the 2nd has ll_b", ->
- (iacts[1].gives(".occurrence").as(".actor") == ll_b).shouldBe true
-
- and_ "ll_c", ->
- (iacts[1].gives(".occurrence").as(".actee") == ll_c).shouldBe true
-
- description "sequence diagram CSS (left, top) width x height for each element", ->
-
- shared_behavior "size and location of occurrence to right", ->
- it_behaves_as "create two objects, activate one of them and interact b/w 2"
- given "the diagram appended into body", ->
- $("body").append diagram
-
- and_ "get the occurrence of obj_b", ->
- @ll_b = iact_a_b.gives(".occurrence").as(".actee")
-
- and_ "get the width of ll_a", ->
- @w_ll_a = ll_a.width()
-
- and_ "get the width of ll_b", ->
- @w_ll_b = parseFloat(ll_b.css("width"))
-
- when_it "set width of all objects 100", ->
- $(".object", diagram).css
- width: 100
- height: 33
-
- and_ "move obj_b to 150px", ->
- obj_b.offset left: 150
-
- and_ "move occurrences to 0", ->
- $(".occurrence", diagram).offset left: 0
-
- and_ "compose occurrences", ->
- diagram.compose()
-
- and_ "get x of ll_a", ->
- @x_ll_a = ll_a.offset().left
-
- and_ "get x of ll_b", ->
- @x_ll_b = ll_b.offset().left
-
- scenario "guarantee 'size and location of occurrence to right'", ->
- it_behaves_as "size and location of occurrence to right"
- then_it "has a body as the parent", ->
- ll_a.parents("body").length.shouldBe 1
-
- then_it "width of ll_a is greater than 0", ->
- ll_a.width().shouldBeGreaterThan 0
-
- then_it "width of ll_a is greater than 0", ->
- w_ll_a.shouldBeGreaterThan 0
-
- and_ "width of ll_b is greater than 0", ->
- w_ll_b.shouldBeGreaterThan 0
-
- and_ "x of ll_a is greater than 0", ->
- x_ll_a.shouldBeGreaterThan 0
-
- and_ "x of ll_a is less than the center of obj_a", ->
- x_ll_a.shouldBeLessThan obj_a.offset().left + obj_a.width() / 2
-
- and_ "x of ll_b is greater than x of obj_b", ->
- x_ll_b.shouldBeGreaterThan obj_b.offset().left
-
- and_ "x of ll_b is less than the center of obj_b", ->
- x_ll_b.shouldBeLessThan obj_b.offset().left + obj_b.width() / 2
-
- and_ "message is toward right", ->
- diagram.$(".message")[0].isTowardRight().shouldBe true
-
- then_it "ll_a.width() > 0", ->
- (ll_a.width() > 0).shouldBe true
-
- and_ "ll_b.width() > 0", ->
- (ll_b.width() > 0).shouldBe true
-
- and_ "obj_a.left() < ll_a.left() < obj_a.hcenter()", ->
- (obj_a.left() < ll_a.left() and ll_a.left() < obj_a.hcenter()).shouldBe true
-
- and_ "obj_b.left() < ll_b.left() < obj_b.hcenter()", ->
- (obj_b.left() < ll_b.left() and ll_b.left() < obj_b.hcenter()).shouldBe true
-
- and_ "ll_a.left() is in [obj_a.left(), obj_a.hcenter()]", ->
- ll_a.left_is_in([ obj_a.left(), obj_a.hcenter() ]).shouldBe true
-
- and_ "ll_b.left() is in [obj_b.left(), obj_a.hcenter()]", ->
- ll_b.left_is_in([ obj_b.left(), obj_b.hcenter() ]).shouldBe true
-
- and_ "_in_(obj_a.left(), ll_a.left(), obj_a.hcenter())", ->
- _in_(obj_a.left(), ll_a.left(), obj_a.hcenter()).shouldBe true
-
- and_ "_in_(obj_b.left(), ll_b.left(), obj_b.hcenter())", ->
- _in_(obj_b.left(), ll_b.left(), obj_b.hcenter()).shouldBe true
-
- shared_behavior "a right message from obj_b to obj_c", ->
- it_behaves_as "size and location of occurrence to right"
- given "a new object which size is 100", ->
- @obj_c = $.jumly(".object").css(
- width: 100
- height: 33
- )
-
- when_it "appending the object into the diagram", ->
- diagram.append obj_c
-
- and_ "move obj_c to 300", ->
- obj_c.offset left: 300
-
- and_ "obj_b interact to obj_c", ->
- @ll_c = ll_b.interact(obj_c).gives(".occurrence").as(".actee")
-
- and_ "compose occurrences", ->
- diagram.compose()
-
- scenario "guarantee 'a right message from obj_b to obj_c'", ->
- it_behaves_as "a right message from obj_b to obj_c"
- then_it "obj_c.left() < ll_c.left() < obj_c.hcenter()", ->
- (obj_c.left() < ll_c.left() and ll_c.left() < obj_c.hcenter()).shouldBe true
-
- and_ "2nd message is toward right", ->
- diagram.$(".message")[1].isTowardRight().shouldBe true
-
- scenario "horizontal positional relation", ->
- given "3 objects", ->
- @a = $.jumly(".object").offset(
- left: 0
- top: 0
- )
- @b = $.jumly(".object").offset(
- left: 100
- top: 0
- )
- @c = $.jumly(".object").offset(
- left: 200
- top: 0
- )
- @diagram = $.jumly(".sequence-diagram").append(a).append(b).append(c)
- $(".object", diagram).width 88
- $("body").append diagram
-
- then_it "a is left at b", ->
- a.isLeftAt(b).shouldBe true
-
- then_it "b is left at c", ->
- b.isLeftAt(c).shouldBe true
-
- then_it "a is left at c", ->
- a.isLeftAt(c).shouldBe true
-
- then_it "b is right at a", ->
- b.isRightAt(a).shouldBe true
-
- then_it "c is right at b", ->
- c.isRightAt(b).shouldBe true
-
- then_it "c is right at a", ->
- c.isRightAt(a).shouldBe true
-
- then_it "a is not left at a(itself)", ->
- (not a.isLeftAt(a)).shouldBe true
-
- then_it "a is not right at a(itself)", ->
- (not a.isRightAt(a)).shouldBe true
-
- shared_behavior "message is sent back from obj_c", ->
- it_behaves_as "a right message from obj_b to obj_c"
- when_it "obj_c interact from ll_c to obj_b", ->
- @ll_b2 = ll_c.interact(obj_b).gives(".occurrence").as(".actee")
-
- and_ "doing re-location", ->
- diagram.compose()
-
- scenario "guarantee 'message is sent back from obj_c", ->
- it_behaves_as "message is sent back from obj_c"
- then_it "obj_b.left() < ll_b2.left()", ->
- obj_b.left().shouldBeLessThan ll_b2.left()
-
- then_it "ll_b2.left() < obj_b.hcenter()", ->
- ll_b2.left().shouldBeEqual obj_b.hcenter()
-
- and_ "1st message is toward right", ->
- diagram.$(".message")[0].isTowardRight().shouldBe true
-
- and_ "2nd message is toward right", ->
- diagram.$(".message")[1].isTowardRight().shouldBe true
-
- and_ "3rd message is toward left", ->
- diagram.$(".message")[2].isTowardLeft().shouldBe true
-
- and_ "ll_b2 is on ll_b", ->
- ll_b2.isOnOccurrence().shouldBe true
-
- and_ "ll_b is a parent occurrence for ll_b2", ->
- (ll_b2.parentOccurrence() == ll_b).shouldBe true
-
- and_ "ll_b doesn't shift", ->
- ll_b.shiftToParent().shouldBe 0
-
- and_ "ll_b2 shifts toward right", ->
- ll_b2.shiftToParent().shouldBe 1
-
- scenario "guarantee 'message is sent back from obj_b to obj_a", ->
- when_it "obj_b interact from ll_b2 to obj_a", ->
- @ll_a2 = ll_b2.interact(obj_a).gives(".occurrence").as(".actee")
-
- and_ "doing re-location", ->
- diagram.compose()
-
- then_it "obj_a.left() < ll_a2.left()", ->
- obj_a.left().shouldBeLessThan ll_a2.left()
-
- then_it "ll_a2.left() < obj_a.hcenter()", ->
- ll_a2.left().shouldBeEqual obj_a.hcenter()
-
- and_ "ll_a is a parent occurrence for ll_a2", ->
- (ll_a2.parentOccurrence() == ll_a).shouldBe true
-
- and_ "ll_a2 shifts toward right", ->
- ll_a2.shiftToParent().shouldBe 1
-
- scenario "left message over obj_b back to obj_a", ->
- it_behaves_as "a right message from obj_b to obj_c"
- when_it "obj_c interact from ll_c to obj_b", ->
- @ll_a2 = ll_c.interact(obj_a).gives(".occurrence").as(".actee")
-
- and_ "composing", ->
- diagram.compose()
-
- and_ "refer msg_ca", ->
- @msg_ca = diagram.$(".message:eq(2)")[0]
-
- then_it "obj_a.left() < ll_a2.left()", ->
- obj_a.left().shouldBeLessThan ll_a2.left()
-
- then_it "ll_a2.left() < obj_a.hcenter()", ->
- ll_a2.left().shouldBeEqual obj_a.hcenter()
-
- and_ "left of msg_ca is on the left of ll_c", ->
- a = msg_ca.offset()
- b = ll_a2.offset()
- a.left.shouldBe b.left
-
- and_ "right of msg_ca is on the right of ll_a", ->
- msg_ca.right().shouldBe ll_c.right()
-
- and_ "(optional case) included canvas's width is equal", ->
- msg_ca.find("canvas").width().shouldBe msg_ca.width()
-
- and_ "ll_a is a parent occurrence for ll_a2", ->
- (ll_a2.parentOccurrence() == ll_a).shouldBe true
-
- shared_behavior "4 objects flowing from left to right", ->
- given "a diagram and 4 objects", ->
- @diagram = $.jumly(".sequence-diagram").append(@obj_a = $.jumly(".object").offset(left: 450).css(
- width: 100
- height: 33
- )).append(@obj_b = $.jumly(".object").offset(left: 300).css(
- width: 100
- height: 33
- )).append(@obj_c = $.jumly(".object").offset(left: 150).css(
- width: 100
- height: 33
- )).append(@obj_d = $.jumly(".object").offset(left: 0).css(
- width: 100
- height: 33
- ))
- diagram.appendTo $("body")
-
- when_it "activating an object of two", ->
- @ll_a = obj_a.activate()
-
- and_ "obj_a interact to obj_b", ->
- @ll_b = ll_a.interact(obj_b).gives(".occurrence").as(".actee")
-
- and_ "locating", ->
- diagram.compose()
-
- scenario "guarantee '4 objects flowing from left to right'", ->
- it_behaves_as "4 objects flowing from left to right"
- then_it "obj_b.left() < ll_b.left() < obj_b.hcenter()", ->
- (obj_b.left() < ll_b.left() and ll_b.left() < obj_b.hcenter()).shouldBe true
-
- shared_behavior "a message toward left over an object", ->
- it_behaves_as "4 objects flowing from left to right"
- when_it "obj_b interact to obj_d over obj_c", ->
- @ll_d = ll_b.interact(obj_d).gives(".occurrence").as(".actee")
-
- and_ "relocating", ->
- diagram.compose()
-
- scenario "guarantee 'a message toward left over an object'", ->
- it_behaves_as "a message toward left over an object"
- then_it "obj_d.left() < ll_d.left() < obj_d.hcenter()", ->
- (obj_d.left() < ll_d.left() and ll_d.left() < obj_d.hcenter()).shouldBe true
-
- scenario "a message toward left over an object", ->
- it_behaves_as "a message toward left over an object"
- when_it "obj_d interact to obj_a over obj_c and obj_b", ->
- @ll_a = ll_d.interact(obj_a).gives(".occurrence").as(".actee")
-
- and_ "relocating", ->
- diagram.compose()
-
- then_it "obj_a.left() < ll_a.left() < obj_a.hcenter()", ->
- (obj_a.left() < ll_a.left() and ll_a.left() < obj_a.hcenter()).shouldBe true
-
- and_ "ll_a is on a occurrence", ->
- ll_a.isOnOccurrence().shouldBe true
-
- and_ "ll_a shifts toward left", ->